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

Don't try to use the colorbar formatter to format RGBA data.#14069

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged

Conversation

anntzer
Copy link
Contributor

@anntzeranntzer commentedApr 28, 2019
edited
Loading

A colorbar doesn't make much sense for RGBA data, but matplotlib does
allow one to be constructed; when formatting the cursor data for a RGBA
image we must be careful to not use the colorbar formatter.

Otherwise, afterplt.imshow(np.random.rand(5, 5, 3)); plt.colorbar(),
when moving the mouse cursor over the image, we get

<elided>  File "/usr/lib/python3.7/site-packages/matplotlib/ticker.py", line 604, in format_data_short    return '%-12g' % value  File "/usr/lib/python3.7/site-packages/numpy/ma/core.py", line 4296, in __float__    raise TypeError("Only length-1 arrays can be converted "TypeError: Only length-1 arrays can be converted to Python scalars

release critical as a regression from#12459.

PR Summary

PR Checklist

  • Has Pytest style unit tests
  • Code isFlake 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

A colorbar doesn't make much sense for RGBA data, but matplotlib doesallow one to be constructed; when formatting the cursor data for a RGBAimage we must be careful to not use the colorbar formatter.Otherwise, after `plt.imshow(np.random.rand(5, 5, 3)); plt.colorbar()`,when moving the mouse cursor over the image, we get```<elided>  File "/usr/lib/python3.7/site-packages/matplotlib/ticker.py", line 604, in format_data_short    return '%-12g' % value  File "/usr/lib/python3.7/site-packages/numpy/ma/core.py", line 4296, in __float__    raise TypeError("Only length-1 arrays can be converted "TypeError: Only length-1 arrays can be converted to Python scalars```
@anntzeranntzer added the Release criticalFor bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions. labelApr 28, 2019
@anntzeranntzer added this to thev3.1.0 milestoneApr 28, 2019
@dstansbydstansby merged commit1009c14 intomatplotlib:masterApr 29, 2019
meeseeksmachine pushed a commit to meeseeksmachine/matplotlib that referenced this pull requestApr 29, 2019
@anntzeranntzer deleted the rgba_colorbar_formatcursordata branchApril 29, 2019 11:37
timhoffm added a commit that referenced this pull requestApr 29, 2019
…069-on-v3.1.xBackport PR#14069 on branch v3.1.x (Don't try to use the colorbar formatter to format RGBA data.)
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@tacaswelltacaswelltacaswell approved these changes

@dstansbydstansbydstansby approved these changes

Assignees
No one assigned
Labels
Release criticalFor bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.
Projects
None yet
Milestone
v3.1.0
Development

Successfully merging this pull request may close these issues.

3 participants
@anntzer@tacaswell@dstansby

[8]ページ先頭

©2009-2025 Movatter.jp