| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
@timhoffm The implementation here is inspired by your comment #30982 (comment) I realized _ColorizerInterface fulfills almost all the requirements for a mappable for colorbar, so instead of defining a protocol, It occured to me that it might be easier to simply define a new class that subclasses _ColorizerInterface. This greatly reduces the complexity of VoxelDict. Let me know what you think :) |
Sorry, something went wrong.
|
@trygvrad I just had a quick look. Overall this looks reasonable. I'm a bit worried on the deep nesting we create here: class _ColorizerInterface: class _ColorbarMappable(_ColorizerInterface): class _ScalarMappable(_ColorbarMappable): class ColorizingArtist(_ScalarMappable, artist.Artist): Do we need all of these? Can we answer the questions: What exactly does each class bring additionally to the table? Why can't that functionality live in the parent or child class. |
Sorry, something went wrong.
Currently we have
In order to have a mappable that is not an artist, we need all the functionality of _ColorizerInterface and some of the functionality of _ScalarMappable. We can solve this by introducing a new class in the hierarchy, but a better option maybe to simply move some of the member functions from _ScalarMappable to _ColorizerInterface, as you @timhoffm suggest. I would personally prefer _ColorbarMappable [or something similar] as a name for the _ColorizerInterface with increased functionality, as this describes what this class can actually be used for [input to fig.colorbar(...)]. I don't think there is currently any use case for _ColorizerInterface outside of ColorizingArtist |
Sorry, something went wrong.
|
This sounds reasonable. We can always recreate a _ColorizerInterface at the top of the hierarchy later if needed. Could you do these architectural changes as a separate PR? I believe it's easier to review/discuss the architecture without the voxels in between. |
Sorry, something went wrong.
Sorry, something went wrong.
There was a problem hiding this comment.
This threads the needle much more cleanly than the last PR, thanks for putting it together. Could you please add a test with a new baseline image, as well as a whats new entry?
Sorry, something went wrong.
| if filled.dtype == np.float64: | ||
| scalars = filled | ||
| filled = np.isfinite(filled) | ||
| #colorizer.autoscale_None(scalars[filled]) |
There was a problem hiding this comment.
| #colorizer.autoscale_None(scalars[filled]) |
Sorry, something went wrong.
There was a problem hiding this comment.
Thank you @scottshambaugh
I will come back to this PR after we figure out #31039
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
PR summary
This PR is in response to and closes #22969 [ENH]: Voxels as mappable for colorbar
The technical implementation builds upon the discussion in PR #30982 (closed)
This change allows axes3d.voxels() to take scalar data as input, and map it to color using a colorbar. The colors are applied to the voxels before shading.
The following code demonstrates the new functionality:
The technical implementation is such that:
Technical implementation
This technical implementation changes the return type of ax.voxel() from dict to the new class VoxelDict.
Where VoxelDict is valid input for fig.colorbar(), but VoxelDict is not itself an artist.
VoxelDict inherits from _ColorbarMappable, a new class introduced in the class hierarchy of ColorizingArtist (colorizer.py).
with these changes, this hierarchy is now:
I believe this change in the class hierarchy is suitable, because it makes explicit the requirements for colorbar.
Next step
First we need a discussion about the merits of the technical implementation.
Note that this implementation allows the user to set new data on existing voxels (which will update the colors), but it does not allow for adding/removing the voxels themselves [this will require more complicated methods, and can be implemented later].
If there is agreement that this implementation is suitable, I will need to add more tests.