Title: [Bug]: Unexpected behavior of the line style specifiers in the histogram method · Issue #29857 · matplotlib/matplotlib · GitHub
Open Graph Title: [Bug]: Unexpected behavior of the line style specifiers in the histogram method · Issue #29857 · matplotlib/matplotlib
X Title: [Bug]: Unexpected behavior of the line style specifiers in the histogram method · Issue #29857 · matplotlib/matplotlib
Description: Bug summary There is a strange change on the behavior of the line style specifiers of the hist method in matplotlib when moving from version 3.9.0 to 3.10.1. It seems like the linestyle and ls arguments are behaving differently. In addit...
Open Graph Description: Bug summary There is a strange change on the behavior of the line style specifiers of the hist method in matplotlib when moving from version 3.9.0 to 3.10.1. It seems like the linestyle and ls argu...
X Description: Bug summary There is a strange change on the behavior of the line style specifiers of the hist method in matplotlib when moving from version 3.9.0 to 3.10.1. It seems like the linestyle and ls argu...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/29857
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Bug]: Unexpected behavior of the line style specifiers in the histogram method","articleBody":"### Bug summary\n\nThere is a strange change on the behavior of the line style specifiers of the `hist` method in `matplotlib` when moving from version 3.9.0 to 3.10.1. It seems like the `linestyle` and `ls` arguments are behaving differently. In addition, it is no longer possible to specify a customized line style for histograms via a tuple `ls=(0, (1, 10))`. This is not the case for the `plot` method.\n\nIn `matplotlib` 3.9.0:\n\n\n\nIn `matplotlib` 3.10.1:\n\n\n\nUsing the `linestyle` argument with `(0, (1, 10))` as a value leads to the following error\n\n```\nValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (2,) + inhomogeneous part.\n```\n\nNote that when using `ls` there is no error, but the result is not what we would expect.\n\n### Code for reproduction\n\n```Python\nimport matplotlib.pyplot as plt\nimport numpy as np\n\nx = np.random.normal(0, 1, 10_000)\n\nfig, ((ax0, ax1), (ax2, ax3)) = plt.subplots(2, 2, figsize=(8, 8))\nax0.plot(x, x, ls=(0, (1, 10)), lw=2)\nax0.set_title(\"scatter plot (ls)\")\nax1.plot(x, x, linestyle=(0, (1, 10)), lw=2)\nax1.set_title(\"scatter plot (linestyle)\")\n# this does not display any error, but the histogram is incorrect\nax2.hist(x, bins=10, range=(-5, +5), ls=(0, (1, 10)), histtype=\"step\", lw=2)\nax2.set_title(\"hist (ls)\")\n# this gives an error in 3.10.1\nax3.hist(x, bins=10, range=(-5, +5), linestyle=(0, (1, 10)), histtype=\"step\", lw=2)\nax3.set_title(\"hist (linestyle)\")\nplt.show()\n```\n\n### Actual outcome\n\nValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (2,) + inhomogeneous part.\n\n### Expected outcome\n\n\n\n### Additional information\n\n_No response_\n\n### Operating system\n\n_No response_\n\n### Matplotlib Version\n\n3.10.1\n\n### Matplotlib Backend\n\n_No response_\n\n### Python version\n\n_No response_\n\n### Jupyter version\n\n_No response_\n\n### Installation\n\nNone","author":{"url":"https://github.com/mramospe","@type":"Person","name":"mramospe"},"datePublished":"2025-04-02T10:04:46.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/29857/matplotlib/issues/29857"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:ea8e6575-7010-9e56-7aa6-38f2d730e0cf |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 92CC:33CA96:255340:313261:6A5189ED |
| html-safe-nonce | 3d595dc7cf2ad91731957d6492df9f0a48ae6498e50304a68b862929a41b6616 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5MkNDOjMzQ0E5NjoyNTUzNDA6MzEzMjYxOjZBNTE4OUVEIiwidmlzaXRvcl9pZCI6IjYxOTY1MDU1MTA1MDM2MTQ5NTciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 5de032721cec2e8d3e62c9e55698c706be3903dda56388caa6ccb18e8f55c2ba |
| hovercard-subject-tag | issue:2965887862 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/matplotlib/matplotlib/29857/issue_layout |
| twitter:image | https://opengraph.githubassets.com/96ea89dc058216cbdeef9a94012a52364cde91f0e4ef19fb88f87112b5e109bf/matplotlib/matplotlib/issues/29857 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/96ea89dc058216cbdeef9a94012a52364cde91f0e4ef19fb88f87112b5e109bf/matplotlib/matplotlib/issues/29857 |
| og:image:alt | Bug summary There is a strange change on the behavior of the line style specifiers of the hist method in matplotlib when moving from version 3.9.0 to 3.10.1. It seems like the linestyle and ls argu... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | mramospe |
| hostname | github.com |
| expected-hostname | github.com |
| None | b9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb |
| turbo-cache-control | no-preview |
| go-import | github.com/matplotlib/matplotlib git https://github.com/matplotlib/matplotlib.git |
| octolytics-dimension-user_id | 215947 |
| octolytics-dimension-user_login | matplotlib |
| octolytics-dimension-repository_id | 1385122 |
| octolytics-dimension-repository_nwo | matplotlib/matplotlib |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1385122 |
| octolytics-dimension-repository_network_root_nwo | matplotlib/matplotlib |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | cb77a7b8b06cd86c243be33fd8e7922d70a9d243 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width