Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Add support for images with units#27721
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
Draft
dstansby wants to merge13 commits intomatplotlib:mainChoose a base branch fromdstansby:image-units
base:main
Could not load branches
Branch not found:{{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline, and old review comments may become outdated.
Uh oh!
There was an error while loading.Please reload this page.
Draft
Changes fromall commits
Commits
Show all changes
13 commits Select commitHold shift + click to select a range
e1a8fee
Basic support for units on ScalarMappable
dstansby0ccb72b
Set units on colorbar axes
dstansbyf2fa21b
Add unit conversion for pcolor methods
dstansby4a7504d
Add support for units in vmin/vmax
dstansby794b4ed
Allow unit registry to look up 2D-like input
dstansby084850b
Add a datetime test to images with units
dstansby979b099
Add support for categorical colorbars
dstansby6832e0f
Allow ticks argument to take units
dstansby8bad4fb
Note where else units can be used with images
dstansby4a7caac
Update collections test
dstansby0a17be9
Add test figure
dstansbyad272c5
Coerce array in pickle tests
dstansby0340538
Change EllipseCollection private attribute name
dstansbyFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
20 changes: 20 additions & 0 deletionsdoc/api/next_api_changes/behavior/27721-DS.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
Unit converters can now support units in images | ||
----------------------------------------------- | ||
`~.cm.ScalarMappable` can now contain data with units. This adds support for | ||
unit-ful data to be plotted using - `~.axes.Axes.imshow`, `~.axes.Axes.pcolor`, | ||
and `~.axes.Axes.pcolormesh` | ||
For this to be supported by third-party `~.units.ConversionInterface`, | ||
the `~.units.ConversionInterface.default_units` and | ||
`~.units.ConversionInterface.convert` methods must allow for the *axis* | ||
argument to be ``None``, and `~.units.ConversionInterface.convert` must be able to | ||
convert data of more than one dimension (e.g. when plotting images the data is 2D). | ||
If a conversion interface raises an error when given ``None`` or 2D data as described | ||
above, this error will be re-raised when a user tries to use one of the newly supported | ||
plotting methods with unit-ful data. | ||
If you have a custom conversion interface you want to forbid using with image data, the | ||
`~.units.ConversionInterface` methods that accept a ``units`` parameter should raise | ||
a `matplotlib.units.ConversionError` when given ``units=None``. |
12 changes: 12 additions & 0 deletionsdoc/users/next_whats_new/image_units.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
Unit support for images | ||
----------------------- | ||
This adds support for image data with units has been added to the following plotting | ||
methods: | ||
- `~.axes.Axes.imshow` | ||
- `~.axes.Axes.pcolor` | ||
- `~.axes.Axes.pcolormesh` | ||
If the data has units, the ``vmin`` and ``vmax`` units to these methods can also have | ||
units, and if you add a colorbar the ``levels`` argument to ``colorbar`` can also | ||
have units. |
39 changes: 31 additions & 8 deletionslib/matplotlib/axes/_axes.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
4 changes: 3 additions & 1 deletionlib/matplotlib/category.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
52 changes: 47 additions & 5 deletionslib/matplotlib/cm.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
22 changes: 11 additions & 11 deletionslib/matplotlib/collections.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
32 changes: 29 additions & 3 deletionslib/matplotlib/colorbar.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletionlib/matplotlib/colorbar.pyi
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletionslib/matplotlib/image.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Binary file addedlib/matplotlib/tests/baseline_images/test_units/mappable_units.png
Loading
Sorry, something went wrong.Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
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.