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
DOC: document fmt_xdata and fmt_ydata #25187
base: main
Are you sure you want to change the base?
Conversation
|
|
||
| fig, ax = plt.subplots() | ||
| ax.set_ylim(-5, 5) | ||
| ax.fmt_ydata = lambda v: f'{v:.3g}' if v > 0 else f'({abs(v):.3g})' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| ax.fmt_ydata = lambda v: f'{v:.3g}' if v > 0 else f'({abs(v):.3g})' | |
| ax.fmt_ydata = lambda v: f'{v:.3g}' if v >= 0 else f'({abs(v):.3g})' |
?
(Not really relevant, but as I happened to see it... And it will consistent with the text below.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think perhaps this should not use abs, as it confused me why you didn't just use it directly instead of having the if, since the parentheses weren't initially obvious. But using -v might make it clear that you're doing the if manually on purpose.
|
Makes sense to add the same to matplotlib/lib/mpl_toolkits/mplot3d/axes3d.py Lines 161 to 162 in 91d8f2e
? This may just as well go in 3.7? (I guess it would if there was a 3.7-doc? Edit: no, not in 3.7-doc as it also changes the lib-files, but still...) |
| #: | ||
| #: The expected signature is :: | ||
| #: | ||
| #: def fmt(val: float,/) -> str: ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comma before the slash, ditto below.
|
|
||
| fig, ax = plt.subplots() | ||
| ax.set_ylim(-5, 5) | ||
| ax.fmt_ydata = lambda v: f'{v:.3g}' if v > 0 else f'({abs(v):.3g})' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think perhaps this should not use abs, as it confused me why you didn't just use it directly instead of having the if, since the parentheses weren't initially obvious. But using -v might make it clear that you're doing the if manually on purpose.
| Position Format | ||
| --------------- | ||
|
|
||
| The location of the cursor is show in the UI and generated via the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| The location of the cursor is show in the UI and generated via the | |
| The location of the cursor is shown in the UI and generated via the |
| The location of the cursor is show in the UI and generated via the | ||
| `~axes.Axes.format_coord` method which in turn calls the | ||
| `~axes.Axes.format_xdata` and `~axes.Axes.format_ydata` methods. The hard | ||
| coded format in `~axes.Axes.format_coord` is ``f'x={formtated_x} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| coded format in `~axes.Axes.format_coord` is ``f'x={formtated_x} | |
| coded format in `~axes.Axes.format_coord` is ``f'x={formatted_x} |
|
Do we want to get this in prior 3.7.1, which we are looking to tag today? |


PR Summary
Closes #9593
This documents the exact call chain so we can leave the monkey patching route implicit ;)