[Matplotlib-devel] Easier tick formatters

Antony Lee antony.lee at institutoptique.fr
Thu Mar 5 10:32:41 EST 2020


The point is that if we support callables, we'll already have all these
cases supported, and while appending `.format` to your string *could* be
considered boilerplate, it's already considerably shorter than
`FuncFormatter` (or any of the others) + the import.  Finally this still
doesn't preclude adding the other cases later.
Supporting None as default seems likely to confuse people who'd think it
means NullFormatter...
Antony

On Thu, Mar 5, 2020 at 3:55 PM Todd <toddrjen at gmail.com> wrote:

> 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.
> _______________________________________________
> Matplotlib-devel mailing list
> Matplotlib-devel at python.org
> https://mail.python.org/mailman/listinfo/matplotlib-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-devel/attachments/20200305/be7c561a/attachment.html>


More information about the Matplotlib-devel mailing list