Skip to content

[MNT]: Not possible to set AutoDateFormatter rcParam to function without deprecation warning #23012

Description

@oscargus

Summary

Not clear if it should be possible, but it is possible to use functions instead of format strings so one may think it should be possible to set the rcParam to a function as well. The documentation is a bit vague and do not really encourage changing them, so maybe it is not supposed to be possible.

`.AutoDateFormatter` has a ``.scale`` dictionary that maps tick scales (the
interval in days between one major tick) to format strings; this dictionary
defaults to ::

In [1]: mpl.rcParams['date.autoformatter.year'] = lambda a: str(a)
C:\Users\Oscar\AppData\Local\Temp\ipykernel_9940\331672118.py:1: MatplotlibDeprecationWarning: Support for setting an rcParam that expects a str value to a non-str value is deprecated since 3.5 and support will be removed two minor releases later.
  mpl.rcParams['date.autoformatter.year'] = lambda a: str(a)

Proposed fix

Add a "string or callable" verifier and use that.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions