FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Proof of concept images with units by dstansby · Pull Request #19481 · matplotlib/matplotlib · GitHub

Repository navigation

Proof of concept images with units - #19481

Closed
dstansby wants to merge 1 commit into
matplotlib:masterfrom
dstansby:image-units
Closed

dstansby wants to merge 1 commit into
matplotlib:masterfrom
dstansby:image-units

Conversation

dstansby commented Feb 8, 2021

Copy link
Copy Markdown
Member

xref #19476

There is likely lots to iron out, and many tests and documentation that would need adding, but I thought I would open this as a proof of concept for images (or more generally mappables) with units. Things that come to mind are:

  • Unit converters expect an axis argument, I'm not sure what to do about this when we have a mappable and not an axis
  • munits.registry.get_converter expects a 1D sequence as input, not 2D, there's probably a way to modify this though

This allows things like this image, where the correct formatter is automatically set on the colorbar:

from datetime import datetime, timedelta
import matplotlib.colors as mcolor
import matplotlib.pyplot as plt

data = [[datetime.now(), datetime.now() - timedelta(seconds=1)],
        [datetime.now(), datetime.now()]]

fig, ax = plt.subplots()
im = ax.imshow(data)
fig.colorbar(im)

plt.show()

jklymak marked this pull request as draft February 8, 2021 15:09
self.mappable = mappable
_add_disjoint_kwargs(kwargs, cmap=mappable.cmap, norm=mappable.norm)

# Set the formatter if

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

See #18900 for changes in how the formatter and locator will work in 3.5

dstansby commented Feb 8, 2021

Copy link
Copy Markdown
Member Author

Thanks for bringing #18900 to my attention. With the context of that and the CZI grant, I think it's probably worth closing this (currently) bare bones attempt to wait for colorbar refactoring and a bit more thought.

dstansby closed this Feb 8, 2021
dstansby deleted the image-units branch September 1, 2021 11:33
dstansby mentioned this pull request Sep 1, 2021
7 tasks done
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL