Skip to content

Reprs on formatters and locaters #21898

Open
@story645

Description

@story645

As discussed in #21874, there aren't reprs on the locators and formatters. Reprs of the form where eval(repr) = call, something like

eval('AutoDateLocator(maxticks=8)') = AutoDateLocator(maxticks)

would mean reprs could be used in the documentation examples, which would help keep the labels in sync. This is useful for the new example #21874 &

I think it's a good first issue 'cause it's fairly standalone and rote if you know classes, only potential difficulty might be in storing the original args:

When I try AutoDateLocator.__repr__ = lambda self: f'AutodateLocator(maxticks={self.maxticks})' then repr(AutoDateLocator(maxticks=8)) returns 'AutodateLocator(maxticks={0: 8, 1: 8, 3: 8, 4: 8, 5: 8, 6: 8, 7: 8})', i.e. the class variable maxticks. I don't know how to get the value passed in during the function call. But even if this is possible, I find defining all the repr rather verbose and a bit hacky as compared to a simple eval.

Originally posted by @StefRe in #21874 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Difficulty: Mediumhttps://matplotlib.org/devdocs/devel/contribute.html#good-first-issuesGood first issueOpen a pull request against these issues if there are no active ones!New featuretopic: ticks axis labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions