8000 [MNT]: Not possible to set `AutoDateFormatter` rcParam to function without deprecation warning · Issue #23012 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content
[MNT]: Not possible to set AutoDateFormatter rcParam to function without deprecation warning #23012
Open
@oscargus

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0