[Matplotlib-devel] Easier tick formatters

Todd toddrjen at gmail.com
Thu Mar 5 09:54:45 EST 2020


On Thu, Mar 5, 2020 at 5:37 AM Antony Lee <antony.lee at institutoptique.fr>
wrote:

> I am sympathetic to the idea.  A much simpler rule, though, would be to
> *just* additionally accept callables.  New-style format string formatters
> can then be implemented by passing bound methods
> (`set_major_formatter("tick {}".format)` -- the bound method quietly
> ignores the second (index) argument), which also makes it explicit that we
> talking about {}-format, not %s-format.  Even
> `set_major_formatter("".format)` would already be much shorter to type than
> importing NullFormatter and using it.  In any case, we could always first
> implement support for callables, which already buys us all these cases, and
> defer further cases to later.
> The only case not covered by callables/bound methods is FixedLocator, but
> this is already handled by set_x/yticks, and anyways (usually) involves
> setting both the locator and the formatter at once (and in fact is
> semantically more associated with setting the locator rather than the
> formatter), so I think it's fine to keep it separate for now.
> Antony
>
>
I thought of that approach, but it seemed like it still requires some
unnecessary boilerplate for what seemed to me to by fairly unambiguous
situations.  And it also doesn't handle resetting the formatter to the
default.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-devel/attachments/20200305/b2c639e0/attachment.html>


More information about the Matplotlib-devel mailing list