Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork8.1k
Closed
Milestone
Description
Bug report
I upgraded matplotlib recently and myboxplot stopped working. I realized it was the keyword positions which was taking in aInt64Index array created by pandas. UsingInt64Index.values fixes this, butplot takes aInt64Index array so can't see why it isn't desirable forboxplot or why it was removed/no longer works.
Code for reproduction
importnumpyasnpimportpandasaspdimportmatplotlib.pyplotaspltdata=np.random.rand(5,2)years=pd.date_range('1/1/2000',periods=2,freq=pd.DateOffset(years=1)).year# Does not workplt.figure()plt.boxplot(data,positions=years)# Worksplt.figure()plt.boxplot(data,positions=years.values)# Worksplt.figure()plt.plot(years,data[0,:])
Actual outcome
Traceback (most recent call last): File "<ipython-input-38-2540b7c8b9eb>", line 6, in <module> plt.boxplot(data, positions=years) File "/Users/Ray/anaconda/lib/python3.6/site-packages/matplotlib/pyplot.py", line 2729, in boxplot zorder=zorder, data=data) File "/Users/Ray/anaconda/lib/python3.6/site-packages/matplotlib/__init__.py", line 1717, in inner return func(ax, *args, **kwargs) File "/Users/Ray/anaconda/lib/python3.6/site-packages/matplotlib/axes/_axes.py", line 3378, in boxplot manage_xticks=manage_xticks, zorder=zorder) File "/Users/Ray/anaconda/lib/python3.6/site-packages/matplotlib/axes/_axes.py", line 3698, in bxp cap_x = np.array([cap_left, cap_right])ValueError: setting an array element with a sequence.Expected outcome
Expect to produce boxplot and label the xaxis '2000, 2001'
Unfortunately I cannot remember which version I previously used...
Matplotlib version
- Operating system: macOS
- Matplotlib version: 2.1.1
- Matplotlib backend (
print(matplotlib.get_backend())): module://ipykernel.pylab.backend_inline - Python version: Python 3.6.3 :: Anaconda custom (x86_64)
- Pandas version: 0.21.1
Installation
conda upgrade matplotlib
p.s. don't have much dev experience but happy to have a crack at this if it is desired.