Skip to content

axes.format_{x,y} data should have a setter #17286

Description

@story645

In the Date tick labels example, the code for setting the cursor coords message overwrites the default formatters:

ax.format_xdata = mdates.DateFormatter('%Y-%m-%d')
ax.format_ydata = lambda x: '$%1.2f' % x  # format the price.

This creates confusion because runs counter to how basically everything else in matplotlib is set via setter but especially the formatters:

ax.xaxis.set_major_formatter(mdates.DateFormatter('%Y'))

and the docs aren't especially clear either on this being a property:

Axes.format_xdata(self, x)

    Return x formatted as an x-value.

    This function will use the fmt_xdata attribute if it is not None, else will fall back on the xaxis major formatter.

To be consistent with the API, I'm proposing properties/functions of the form:

  • ax.{x,y}data_formatter(mdates.DateFormatter('%Y-%m-%d'))
  • ax.data_formatter(which=(x,y, both), mdates.DateFormatter('%Y-%m-%d'))

Metadata

Metadata

Assignees

No one assigned

    Labels

    API: consistencyConsistency of the matplotlib API, including naming, behavior, defaults, …keepItems to be ignored by the “Stale” Github Action

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions