Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Description
Bug summary
There is a strange change on the behavior of the line style specifiers of thehist
method inmatplotlib
when moving from version 3.9.0 to 3.10.1. It seems like thelinestyle
andls
arguments are behaving differently. In addition, it is no longer possible to specify a customized line style for histograms via a tuplels=(0, (1, 10))
. This is not the case for theplot
method.
Inmatplotlib
3.9.0:
Inmatplotlib
3.10.1:
Using thelinestyle
argument with(0, (1, 10))
as a value leads to the following error
ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (2,) + inhomogeneous part.
Note that when usingls
there is no error, but the result is not what we would expect.
Code for reproduction
importmatplotlib.pyplotaspltimportnumpyasnpx=np.random.normal(0,1,10_000)fig, ((ax0,ax1), (ax2,ax3))=plt.subplots(2,2,figsize=(8,8))ax0.plot(x,x,ls=(0, (1,10)),lw=2)ax0.set_title("scatter plot (ls)")ax1.plot(x,x,linestyle=(0, (1,10)),lw=2)ax1.set_title("scatter plot (linestyle)")# this does not display any error, but the histogram is incorrectax2.hist(x,bins=10,range=(-5,+5),ls=(0, (1,10)),histtype="step",lw=2)ax2.set_title("hist (ls)")# this gives an error in 3.10.1ax3.hist(x,bins=10,range=(-5,+5),linestyle=(0, (1,10)),histtype="step",lw=2)ax3.set_title("hist (linestyle)")plt.show()
Actual outcome
ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (2,) + inhomogeneous part.
Expected outcome
Additional information
No response
Operating system
No response
Matplotlib Version
3.10.1
Matplotlib Backend
No response
Python version
No response
Jupyter version
No response
Installation
None