GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — Multivariate plotting in imshow, pcolor and pcolormesh by trygvrad · Pull Request #29221 · matplotlib/matplotlib Conversation
Contributor
PR summaryThis PR continues the work of #28658 and #28454, aiming to close #14168. Features included in this PR:
Features not included in this PR:
PR checklist
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Contributor
Author
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
This was referenced
trygvrad
force-pushed
the
multivariate-norm
branch
from
5afd692 to
90680bd
Compare
trygvrad
force-pushed
the
multivariate-norm
branch
from
90680bd to
206c9b8
Compare
Contributor
Author
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
story645
reviewed
Uh oh!
There was an error while loading. Please reload this page. Uh oh!
There was an error while loading. Please reload this page. Uh oh!
There was an error while loading. Please reload this page. Uh oh!
There was an error while loading. Please reload this page. Uh oh!
There was an error while loading. Please reload this page. Uh oh!
There was an error while loading. Please reload this page. Uh oh!
There was an error while loading. Please reload this page. Uh oh!
There was an error while loading. Please reload this page. Uh oh!
There was an error while loading. Please reload this page. Uh oh!
There was an error while loading. Please reload this page.
trygvrad
force-pushed
the
multivariate-norm
branch
from
d4215a3 to
e30e7e6
Compare
|
There was an error while loading. Please reload this page.
|
@story645 also: this will need a squash-merge |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
e30e7e6 to
f936378
Compare
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
| # pass scalar data | ||
| # and already formatted data | ||
| return data | ||
| elif data.dtype in [np.complex64, np.complex128]: |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Option 1 please.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
| if A.ndim == 3 and A.shape[-1] == 1: | ||
| A = A.squeeze(-1) # If just (M, N, 1), assume scalar and apply colormap. | ||
| if not (A.ndim == 2 or A.ndim == 3 and A.shape[-1] in [3, 4]): | ||
| if A.ndim == 3 and A.shape[0] == 2: |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
to verify, these are here as a hint to the user to use multi-variate color maps and data that would have failed before would still fail now?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Yes, that is the intention
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| raise TypeError(f"Image data of dtype {A.dtype} cannot be " | ||
| f"converted to float") | ||
| else: | ||
| for key in A.dtype.fields: |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I think this fails to catch n_input >1 + non-float-like + non-structured data?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This might be true.
I'm trying to think of a data type that can not be cast to float and is not structured in order to test this
If you try something with data type object, it depends a bit on the shape, all the cases I have tried have been caught:
fig, ax = plt.subplots() im = np.empty((5,5), dtype='object') ax.imshow(im, cmap='BiOrangeBlue') > ValueError: Invalid data entry for mutlivariate data. The data must contain complex numbers, or have a first dimension 2, or be of a dtype with 2 fields im = np.empty((2,5,5), dtype='object') ax.imshow(im, cmap='BiOrangeBlue') > TypeError: Image data of dtype [('f0', 'O'), ('f1', 'O')] cannot be converted to a sequence of floats
Where the first error originates in colorizer._ensure_multivariate_data()
Do you have some idea of other tests I should run, or do we want to have specific tests for _normalize_image_array()?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
| Check validity of image-like input *A* and normalize it to a format suitable for | ||
| Image subclasses. | ||
| """ | ||
| A = mcolorizer._ensure_multivariate_data(n_input, A) |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
minor thing. bit jarring that sometimes the API in f(n_input, A) and othertimes f(A, n_input). I think we should prefer f(A, n_input) everywhere for internal consistency and no-API change on existing functions (like the one we are in now).
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This is a good comment :) I will try to address it soon
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I changed the call signature of colorizer._ensure_multivariate_data(...) to colorizer._ensure_multivariate_data(A, n_input)
I looked to see if there were any other functions with a similar signature which should be flipped, but I did not find any in my quick search.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
63e789a to
7fc99b5
Compare
|
If you've got the bandwidth, @greglucas can you give this a look (skim) since you've been working on colormapping? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
7fc99b5 to
dc6dee7
Compare
There was an error while loading. Please reload this page.
|
@story645 @tacaswell would you two be willing to finish your review of this? EDIT: my apologies @story645 I didn't see you had just assigned this when I wrote my comment :) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@anntzer asked if the more cleanup/refactor/not directly necessary for implementation parts of this PR could be spun off into a different set and if this PR could get rebased to clean up the commit history. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
@anntzer I'll see what I can do. I'll also see if there are some misc changes that can be a separate PR between 1 and 2. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I guess it doesn't really matter, because we know the end result thanks to this PR anyways. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@anntzer @story645 I opened PRs: Hopefully this is easier to review :) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
If an image is shown, and the user hovers over the image, the value at that coordinate should be displayed. The number formating is handled by colorizer.Colorizer._format_cursor_data_override(). This is now updated to also handle the case where a MultiNorm is used (i.e. a bivariat or multivariate colormap), in which case multiple values are displayed.
The previous version of this test passed for numpy 1.x but not for 2.x. This should pass for both
Co-authored-by: Thomas A Caswell <[email protected]>
changed from colorizer._ensure_multivariate_data(n_input, A) to colorizer._ensure_multivariate_data(A, n_input)
29093b3 to
fa40bef
Compare
There was an error while loading. Please reload this page.
Should this be closed if it's superseded? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Yes :) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
Feature request: Bivariate colormapping
There was an error while loading. Please reload this page.