Tweak Formatter method docstrings.#31392
Conversation
timhoffm
left a comment
There was a problem hiding this comment.
Some clarification comments.
Semi-OT: Should we constrain the public API?
In particular, I don't think set_locs is needed publically. Calling format_ticks(values) should be sufficent and it should be possible to make the locs state an implementation detail.
Additionally, one could check / clarify the relation of __call__ and format_data. Are both needed publically?
lib/matplotlib/ticker.py
Outdated
| Return a short string version of a value (defaulting to | ||
| `.Formatter.format_data`), to be used for the mouseover text. | ||
| Defaults to the position-independent long value. | ||
| The mouseover text can be customized by setting the ``Axes.fmt_xdata`` | ||
| and ``Axes.fmt_ydata`` attributes. |
There was a problem hiding this comment.
| Return a short string version of a value (defaulting to | |
| `.Formatter.format_data`), to be used for the mouseover text. | |
| Defaults to the position-independent long value. | |
| The mouseover text can be customized by setting the ``Axes.fmt_xdata`` | |
| and ``Axes.fmt_ydata`` attributes. | |
| Return a short string version of *value*, used for the mouseover text. | |
| This defaults to the long version `.Formatter.format_data`, but | |
| subclasses may override this. | |
| Note: The user can override the mouseover text by setting the | |
| ``Axes.fmt_xdata`` and ``Axes.fmt_ydata`` attributes. |
There was a problem hiding this comment.
Went for a slightly different version where I drop the mention of "long" and "short" (in fact format_data_short can easily be longer than format_data).
lib/matplotlib/ticker.py
Outdated
| Return the tick labels for all the ticks at once. | ||
| This method is used to generate tick labels. |
There was a problem hiding this comment.
| Return the tick labels for all the ticks at once. | |
| This method is used to generate tick labels. | |
| Return the tick labels strings for all *values*. | |
| This method is the public API to generate a meaningful format | |
| for a set of values, e.g. ensures an appropriate precision. |
|
The formatter API is a bit all over the place and I had tried a long time ago to rework it in #5804, but that went nowhere. Here I'm just trying to document the status quo. |
In particular, make it explicit which methods are used for what purpose.
|
I've created #31396 as a tracking issue for possible future formatter API changes. |
In particular, make it explicit which methods are used for what purpose.
PR summary
AI Disclosure
PR checklist