| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
I like this and agree it makes a lot more sense, but... If someone calls formatter() for some reason (old custom axis of some sort?) it still needs to do the interdependent calculation, doesn’t it? I’m just not at all clear that we could move the interdependent code from LogFormatter.__call__ into this function without breaking someone’s code. I’m also not clear what now goes in __call__ |
Sorry, something went wrong.
|
For ConciseDateFormatter, you'd just write a stub __call__ that calls format_ticks and extracts the single relevant value (perhaps the base __call__ could even check whether format_ticks is overridden by the subclass (the check is necessary to avoid infinite recursion between format_ticks and __call__...), and, if it is, defer to it -- it's not that hard to do). Yes, that's a bit slower, but that only affects third party callers and simplifies the implementation quite a bit so I think it's worth it. |
Sorry, something went wrong.
|
So, can you implement LogFormatter with the new method? |
Sorry, something went wrong.
There was a problem hiding this comment.
modulo an api_changes or whats_new entry.
Sorry, something went wrong.
|
As per above - needs change log and ideally a real-world example... |
Sorry, something went wrong.
There was a problem hiding this comment.
Apart from the one suggested API change, and the need for an API note, I like this.
Sorry, something went wrong.
|
The real-world example is basically ConciseDateFormatter (happy to rewrite it using this API after the ConciseDateFormatter is merged). |
Sorry, something went wrong.
|
Happy to do it the other way around if that makes more sense. |
Sorry, something went wrong.
|
I think it makes more sense to get ConciseDate in first and then we'll be better able to see whether this PR fixes the design properly, or if we need some other API. |
Sorry, something went wrong.
|
ping @anntzer ConciseDateFormatter is now in, so this can be looked at again? I'm not sure how this plays with the issues of the minor locator ignoring major ticks. They are separate issues, right? |
Sorry, something went wrong.
|
Pushed an adaptation of ConciseDateFormatter using the format_ticks API, it is a bit simpler. |
Sorry, something went wrong.
|
LGTM! Still needs the API change note? |
Sorry, something went wrong.
This is useful especially when labels are interdependent (e.g. ConciseDateFormatter, but also LogFormatter which currently relies on set_locs, etc.). Because `set_major_formatter`/`set_minor_formatter` (somewhat unusually) enforces that its argument is a Formatter subclass, even third-party formatters will inherit from the base class and have this method defined.
|
added whatsnew |
Sorry, something went wrong.
|
I think I made a mistake while reimplementing ConciseDateFormatter; namely, the "compression" should be used regardless of whether show_offset is True or False and show_offset only controls whether offset_string is set. Force-pushed a fix restoring the behavior as intended by @jklymak. |
Sorry, something went wrong.
|
ooops, thanks for catching that.... |
Sorry, something went wrong.
|
Travis failure is the unrelated, spurious wqy-zenhei.ttc test. |
Sorry, something went wrong.
|
Apologies if not the right place. This PR has the following side effect: fig, ax = plt.subplots()
data = np.clip(randn(250, 250)*1000, 0, 1000)
cax = ax.imshow(data, norm=mpl.colors.LogNorm(vmin=1, vmax=1000))
cbar = fig.colorbar(cax, format='%d')
cbar.minorticks_off()
cbar.set_ticks([5, 10, 100])
plt.show()Prior to this PR, minor ticks would remain off after set_ticks when they had been turned off. After this PR, they come back on. Edit: Comment is wrong, this PR did not change this. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
This is useful especially when labels are interdependent (e.g.
ConciseDateFormatter, but also LogFormatter which currently relies on
set_locs, etc.). xref #10841, maybe of interest for @jklymak.
Because set_major_formatter/set_minor_formatter (somewhat unusually)
enforces that its argument is a Formatter subclass, even third-party
formatters will inherit from the base class and have this method
defined.
PR Summary
PR Checklist