Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Bug]: Unexpected behavior of the line style specifiers in the histogram method #29857

Closed as duplicate of#29717
Milestone
@mramospe

Description

@mramospe

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:

Image

Inmatplotlib 3.10.1:

Image

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

Image

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp