GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Fix passing singleton sequence-type styles to hist by rcomer · Pull Request #29719 · matplotlib/matplotlib

Conversation

@rcomer

@rcomer rcomer commented Mar 8, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

PR summary

Fixes #29717. Use of np.atleast_1d here is not appropriate for style properties expressed as tuples or array-likes. For colours we can just use to_rgba_array. For linestyles I factored out the logic used to set one or more linestyles in Collection.

We are already using to_rgba_array if colors is passed:

matplotlib/lib/matplotlib/axes/_axes.py

Lines 6997 to 6998 in 70d0bf7

else:
colors = mcolors.to_rgba_array(color)

PR checklist

  • "closes #0000" is in the body of the PR description to link the related issue
  • new and changed code is tested
  • [n/a] Plotting related features are demonstrated in an example
  • [n/a] New Features and API Changes are noted with a directive and release note
  • [n/a] Documentation complies with general and docstring guidelines

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@rcomer rcomer added the PR: bugfix Pull requests that fix identified bugs label Mar 8, 2025
@github-actions github-actions Bot added the topic: collections and mappables label Mar 8, 2025
@rcomer

rcomer commented Mar 8, 2025

Copy link
Copy Markdown
Member Author

OK so we can't just use to_rgba_array if the colour is "none", which doesn't happen in the tests but does in the docs...

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@rcomer
Fix passing singleton sequence-type styles to hist
01b27b0
@rcomer
rcomer force-pushed the hist-styles branch from b1d1b6a to 01b27b0 Compare March 8, 2025 18:32
@rcomer rcomer closed this Mar 8, 2025
@rcomer
rcomer deleted the hist-styles branch March 8, 2025 18:45
@rcomer
rcomer restored the hist-styles branch March 8, 2025 18:46
@rcomer rcomer reopened this Mar 8, 2025
@story645

story645 commented Mar 9, 2025

Copy link
Copy Markdown
Member

OK so we can't just use to_rgba_array if the colour is "none",

Is this related to #28475?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@rcomer

rcomer commented Mar 9, 2025

Copy link
Copy Markdown
Member Author

OK so we can't just use to_rgba_array if the colour is "none",

Is this related to #28475?

Yes exactly. The array has zero size, so you get a StopIteration error when you try to call next.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

timhoffm
timhoffm approved these changes Mar 10, 2025
View reviewed changes

@timhoffm timhoffm left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have been pondering for a time whether we should have an internal helper to loop over possibly list-type properties. This should take care of all the technical details like single value vs. list of values, properly handling sequence-like single values, optionally length checks (we currently don't have a clear policy whether we request the same size, or whether we are permissive and continuously cycle as long as needed, which may be handy in some cases but could hide a bug in others).

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

story645 and rcomer reacted with thumbs up emoji
All reactions
  • 👍 2 reactions
@rcomer rcomer added this to the v3.10.2 milestone Mar 11, 2025
story645
story645 approved these changes Mar 11, 2025
View reviewed changes
@story645
story645 merged commit 4b68626 into matplotlib:main Mar 12, 2025
meeseeksmachine pushed a commit to meeseeksmachine/matplotlib that referenced this pull request Mar 12, 2025
@story645 @meeseeksmachine
Backport PR matplotlib#29719: Fix passing singleton sequence-type sty…
6bc61bb
…les to hist
@meeseeksmachine meeseeksmachine mentioned this pull request Mar 12, 2025
Backport PR #29719 on branch v3.10.x (Fix passing singleton sequence-type styles to hist) #29735
Merged
story645 added a commit that referenced this pull request Mar 12, 2025
@story645
Merge pull request #29735 from meeseeksmachine/auto-backport-of-pr-29…
519b3e5
…719-on-v3.10.x

Backport PR #29719 on branch v3.10.x (Fix passing singleton sequence-type styles to hist)
@rcomer
rcomer deleted the hist-styles branch March 12, 2025 10:27
@rcomer rcomer mentioned this pull request Apr 2, 2025
[Bug]: Unexpected behavior of the line style specifiers in the histogram method #29857
Closed
@jklymak jklymak mentioned this pull request Apr 21, 2025
[Bug]: when using histtype, linestyle is not carried through to plot #29955
Closed
@rcomer rcomer mentioned this pull request Apr 29, 2025
[Bug]: Setting the edgecolor when using ax.hist raises Invalid RGBA argument in >=3.10 #29985
Closed
@ksunden ksunden mentioned this pull request May 9, 2025
merge up 3.10.3 #30031
Closed
5 tasks
@ksunden ksunden mentioned this pull request Jul 25, 2025
Manual Backport PR #30195 on branch v3.10.x (ci: Enable wheel builds on Python 3.14) #30356
Merged
5 tasks
@ksunden ksunden mentioned this pull request Aug 7, 2025
merge up v3.10.5 #30401
Merged
5 tasks
@rcomer rcomer mentioned this pull request Dec 4, 2025
Consolidate style parameter handling for plotting methods that call other plotting methods #30808
Merged
4 of 5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@story645 story645 story645 approved these changes
@timhoffm timhoffm timhoffm approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

PR: bugfix Pull requests that fix identified bugs topic: collections and mappables

Projects

None yet

Milestone

v3.10.3

Development

Successfully merging this pull request may close these issues.

[Bug]: Using a linestyle tuple with a histogram crashes with matplotlib 3.10

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@rcomer @story645 @timhoffm
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.