8000 axes.format_{x,y} data should have a setter · Issue #17286 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
story645 opened this issue Apr 30, 2020 · 3 comments
Open

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

story645 opened this issue Apr 30, 2020 · 3 comments

Comments

@story645
Copy link
Member

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'))
@anntzer
Copy link
Contributor
anntzer commented Apr 30, 2020

Really this should be called something like set_xcursor_formatter, data is just too vague.

@story645
Copy link
Member Author

Agree, and should also steal from #16715 that it should take a str, callable, or mticker instance.

@story645
Copy link
Member Author
story645 commented May 4, 2020

And xref #9593 'cause fixing this issue should maybe help fix that one?

@tacaswell tacaswell added this to the v3.4.0 milestone May 4, 2020
@QuLogic QuLogic modified the milestones: v3.4.0, v3.5.0 Jan 27, 2021
@QuLogic QuLogic modified the milestones: v3.5.0, v3.6.0 Sep 25, 2021
@QuLogic QuLogic modified the milestones: v3.6.0, v3.7.0 Aug 24, 2022
@QuLogic QuLogic modified the milestones: v3.7.0, future releases Jan 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants
0