Skip to content

Fix step plots with hue #6944

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Aug 25, 2022
Merged

Fix step plots with hue #6944

merged 5 commits into from
Aug 25, 2022

Conversation

mgunyho
Copy link
Contributor

@mgunyho mgunyho commented Aug 22, 2022

This PR fixes the broadcasting error when trying to plot multiple step plots, like arr.plot.step(..., hue=...) or arr.plot(..., drawstyle="steps-mid"). Previously, this raised a shape error, as mentioned in #4288 (comment). Some other relevant work was started (but apparently unfinished) in #4868 and #4866, this doesn't implement those.

  • Tests added
  • Fixes applied
  • User visible changes (including notable bug fixes) are documented in whats-new.rst

@mathause
Copy link
Collaborator

This looks good - but from staring at the code it seems to me the logic is the same as before?

@mgunyho
Copy link
Contributor Author

mgunyho commented Aug 25, 2022

It may appear so but it's not: np.array([xval, yval]) causes ValueError: could not broadcast input array from shape (100,7) into shape (100) (as well as a warning about ragged arrays) when yval is 2D.

Copy link
Collaborator

@mathause mathause left a comment

Choose a reason for hiding this comment

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

Ah it goes wrong in _valid_other_type(np.array([xval, yval]), [pd.Interval]) - got it.

Could you merge master then I can press the button.

@mathause mathause added the plan to merge Final call for comments label Aug 25, 2022
Copy link
Member

@andersy005 andersy005 left a comment

Choose a reason for hiding this comment

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

Looks solid to me 👍🏽. @mgunyho, thank you for this addition, and welcome to the Xarray community 🎉

@andersy005 andersy005 merged commit 434f9e8 into pydata:main Aug 25, 2022
@mgunyho mgunyho deleted the fix-steps-hue branch August 28, 2022 12:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants