-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Expanded documentation of Axis.set_ticks as per discussion in issue #22262 #22270
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
Conversation
Oops, some merge commit seems to have got caught in the PR, which wasn't intended... |
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.
Thank you for opening your first PR into Matplotlib!
If you have not heard from us in a while, please feel free to ping @matplotlib/developers
or anyone who has commented on the PR. Most of our reviewers are volunteers and sometimes things fall through the cracks.
You can also join us on gitter for real-time discussion.
For details on testing, writing docs, and our review process, please see the developer guide
We strive to be a welcoming and open project. Please follow our Code of Conduct.
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.
Thanks for the suggestions. There is a balance between brevity and clarity - I think this is too verbose for a method docstring...
lib/matplotlib/axis.py
Outdated
List of tick locations. | ||
labels : list of str, optional | ||
List of tick labels. If not set, the labels show the data value. | ||
|
||
.. warning:: | ||
Setting *labels=None* does not guarantee that labels for all | ||
set ticks will be automatically generated - this depends | ||
on the :class:`~matplotlib.ticker.Formatter` of the axis. | ||
Some tick label formatters, e.g. | ||
:class:`~matplotlib.ticker.ScalarFormatter` (default for | ||
plots made with :meth:`~.Axes.plot`) will make | ||
labels for custom ticks, while | ||
others like e.g. | ||
:class:`~matplotlib.ticker.LogFormatterSciNotation` | ||
(default for :meth:`~.Axes.semilogy` plots) may not. | ||
Supply all tick labels in the *labels* parameter if you | ||
want to be sure. | ||
|
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 PR adds a lot of verbiage for a particular edge case. Suggest something more concise...
List of tick locations. | |
labels : list of str, optional | |
List of tick labels. If not set, the labels show the data value. | |
.. warning:: | |
Setting *labels=None* does not guarantee that labels for all | |
set ticks will be automatically generated - this depends | |
on the :class:`~matplotlib.ticker.Formatter` of the axis. | |
Some tick label formatters, e.g. | |
:class:`~matplotlib.ticker.ScalarFormatter` (default for | |
plots made with :meth:`~.Axes.plot`) will make | |
labels for custom ticks, while | |
others like e.g. | |
:class:`~matplotlib.ticker.LogFormatterSciNotation` | |
(default for :meth:`~.Axes.semilogy` plots) may not. | |
Supply all tick labels in the *labels* parameter if you | |
want to be sure. | |
List of tick locations. The axis `.Locator` is replaced by a `.FixedLocator`. Some | |
default tick formatters will not label arbitrary ticks, so pass *label* if needed. | |
labels : list of str, optional | |
List of tick labels. If not set, the labels are generated with the axis tick `.Formatter`. |
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.
Yes, I know my suggestion is quite verbose. I wanted to make the contradiction of actual behaviour with the claim that "If not set, the labels show the data value." very explicit to the reader, hence the big block of text.
At least for me, speaking from a user perspective, initially it was not at all comprehensible as to why without knowledge of the internals of tick labeling.
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 am thinking to perhaps change the last clause "if needed" to "to ensure labels are shown" to explicitly make the point of why labels are needed.
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.
This should be put into the right perspective. Most cases, in particular the defaults, are fine without labels. The main purpose for labels is putting explicit values that cannot be derived from the positions using a formatter.
Formatters not generating labels for certain values is quite an edge case (I didn't even know we have that). Do we know which formatters are affected at all? If so they should be listed explicitly.
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 LogFormatter will not label non-decade labels, unless you override labelOnlyBase
. I don't know if there are others...
lib/matplotlib/axis.py
Outdated
ticks = axes.get_yticks() | ||
ticks_ext = np.append(ticklist, special_ticks) | ||
axes.set_yticks(ticks_ext) | ||
|
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 don't think this block of changes should go in. The first paragraph is in my suggested change above, and the rest is too specialized for a method docstring.
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.
Ok, I concede that I put in a lot here. If this is too much, maybe put it in an example titled "Adding custom ticks to an axis", or somewhere else where it would be appropriate, as official guidance for this kind of problem?
In honesty, I got to the doc for Axes.set_yticks
from some accepted StackOverflow answer that proposes a flawed solution, e.g. this one in the second part when looking how to approach the task I had in mind.
Co-authored-by: Jody Klymak <jklymak@gmail.com>
lib/matplotlib/axis.py
Outdated
`.FixedLocator`. Some default tick formatters will not label | ||
arbitrary ticks, so pass *label* to ensure labels are visible. |
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 don't think we should add that second sentence. It's a workaround for another issue. Instead we should
- Document at the respective formatters that they don't generate labels for certain positions.
- In theory that would be enough. If people use a
LogFormatterSciNotation
they should refer to its docs if it does not format as expected. The issue is thatplt.loglog
implicitly switches to this formatter, so people won't know. One should investigate whether empty labels can also occur at positions issued from the corresponding formatter. If not, only special user-defined positions will run into the empty-label issue, which means we can issue a warning on empty labels without annoying regular users.
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.
Document at the respective formatters that they don't generate labels for certain positions.
Implementing your suggestions goes a bit further than the very small PR that I started from - should e.g. adding docs to Formatter
s be continued here or split off into some other PR?
In theory that would be enough. If people use a
LogFormatterSciNotation
they should refer to its docs if it does not format as expected. The issue is thatplt.loglog
implicitly switches to this formatter, so people won't know.
Yes, this implicit Formatter
switching is the gotcha here, since it breaks the behaviour that the user (ignorant of the internals) would expect - namely I set the ticks, so I should get labels on them, which got me here in the first place.
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.
One should investigate whether empty labels can also occur at positions issued from the corresponding formatter.
Regarding the problem of Locator
-Formatter
correspondence (I hope I am understanding you correctly): from the issue discussion and my (limited) knowledge of the code, I grasp that is a "gentlemen's agreement" without any explicit mechanism ensuring Locator
will not generate ticks that Formatter
will not make labels for.
Digging through the code, I found that the choice of Locator
and Formatter
pairs is in the set_default_locators_and_formatters
override methods of ScaleBase
subclasses (in scale.py). Do you mean going through all possible combinations and analyzing their interactions...?
If not, only special user-defined positions will run into the empty-label issue, which means we can issue a warning on empty labels without annoying regular users.
I am not certain what you mean by "we can issue a warning on empty labels without annoying regular users." - in this docstring, that this is only relevant when setting ticks manually? Or somewhere else, or at runtime (?)
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 don't think we should add that second sentence. It's a workaround for another issue. Instead we should
- Document at the respective formatters that they don't generate labels for certain positions.
- In theory that would be enough. If people use a
LogFormatterSciNotation
they should refer to its docs if it does not format as expected. The issue is thatplt.loglog
implicitly switches to this formatter, so people won't know. One should investigate whether empty labels can also occur at positions issued from the corresponding formatter. If not, only special user-defined positions will run into the empty-label issue, which means we can issue a warning on empty labels without annoying regular users.
You can issue a runtime warning if you want, but I don't see that adding a sentence that says what to do if you don't get the expected results is a bad thing to do. The heuristics for such a runtime warning seem brittle to me.
lib/matplotlib/axis.py
Outdated
Do not mix automatically and manually placed ticks with this method. | ||
See :ghissue:`22262` for discussion. |
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.
Can try you write this down more explicitly? If we write down extra comment they must be easily understandable for the user. Without having looked at #22262, this doesn't make sense to me. I either have a Locator
that automatically places ticks, or I have set tick positions explicitly, which results in a FixedLocator
. How can I mix both? Generally, I'm 👎 on referring to GitHub issues for explanation. They are a historic record of a discussion but not a condensed and easy to understand description.
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 problem with mixing auto and manual ticks comes from a simple and very naive idea of how to add a special tick to an existing axis. Essentially getting and appending to the list of ticks already on the axis:
ticks = axes.get_yticks()
ticks_added = np.append(ticks, [1.234])
axes.set_yticks(ticks_added)
For an outside user, there is nothing to suggest that this shouldn't be done and in itself it doesn't look that unreasonable to do. But it turns out to be an edge case where the underlying implementation leaks through.
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 can try to reformulate this more explicitly in words, but I think it can't really get any better than the code. But then again, that is a bit verbose.
My intent is to warn any future users that could fall into this same trap when trying to approach the task in this deceptively simple way.
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.
There's more, actually, not limited to the edge case. The edge case just results in the Locator
changing unilaterally without the Formatter
changing to match it, as is normally the case when the plot is made, and extra ticks appearing in places not expected by the Formatter
(the "gentlemen's agreement" is broken).
But in this case, even if all ticks are set manually, this will pop up whenever a tick is set to something other than what the Formatter
is trained to expect from the default Locator
for the type of plot.
The warning to not mix auto and manual ticks comes from the issue discussion, but the problem of unlabeled ticks is not directly related to the mixing itself, if one thinks about it carefully.
So I guess this last sentence can be deleted if it is made clear enough that the problem lies with the Formatter
alone.
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.
So I guess this last sentence can be deleted if it is made clear enough that the problem lies with the Formatter alone.
Do you think the above description makes it clear enough?
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.
Yes, I believe so.
I have further tested to make sure that even this apparently discouraged mixing will work, so there is no need for this sentence.
The test:
xs = np.linspace(0, L, 101)
ys = 0.05 / np.abs(np.exp(-xs))
fig = plt.figure()
axes = fig.subplots()
axes.semilogy(xs, ys)
sticx = np.append(axes.get_yticks(), [0.1, 0.5, 1, 2, 4, 10])
sticlbl = [f"{tick:g}" for tick in sticx]
axes.set_yticks(sticx, labels=sticlbl)
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.
Test of the same "naive" method on both axes with loglog
plot:
xs = np.linspace(0, L, 101)
ys = 0.05 / np.abs(np.exp(-xs))
fig = plt.figure()
axes = fig.subplots()
axes.loglog(xs, ys)
sticx = np.append(axes.get_xticks(), [0.1, 0.25, 0.5, 1, 2, 4, 6])
sticxlbl = [f"{tick:g}" for tick in sticx]
sticy = np.append(axes.get_yticks(), [0.1, 0.5, 1, 2, 4, 10])
sticylbl = [f"{tick:g}" for tick in sticy]
axes.set_xticks(sticx, labels=sticxlbl)
axes.set_yticks(sticy, labels=sticylbl)
lib/matplotlib/axis.py
Outdated
Do not mix automatically and manually placed ticks with this method. | ||
See :ghissue:`22262` for discussion. |
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.
So I guess this last sentence can be deleted if it is made clear enough that the problem lies with the Formatter alone.
Do you think the above description makes it clear enough?
Co-authored-by: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com>
Some cryptic issue is failing the docs build...? |
Co-authored-by: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com>
Thanks @yaaun! |
_axstack whitespace _parent._axstack move clear functions into figurebase clear subfigures first Clear child subfigures tests move property back to init changelog reduce changelog TEST: partial subfig clearing Clear all children subfigs in parent Clear toolbars only in Figure Restore whitespace on :684 flake8 old comment TITLE UNDERLINE Expire mathttext-related deprecations Fixed review comments and a few more removals Use PNG image as the icon for Tk plot windows Fix loading user-defined icons for Tk toolbar Co-Authored-By: Elliott Sales de Andrade <quantum.analyst@gmail.com> Prevent tooltips from overlapping buttons in NavigationToolbar2Tk Update doc/api/next_api_changes/behavior/22135-JSS3.rst Co-authored-by: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com> Fix loading user-defined icons for Qt plot window Update both zoom/pan states on wx when triggering from keyboard. Previously, typing "o" and "p" on a wx window would result in both the zoom and the pan button being pressed at the same time. Fix that by relying on the same strategy as all other backends. Switch transOffset to offset_transform. Note that most APIs *previously* already accepted *offset_transform* as kwarg, due to the presence of the `set_offset_transform` setter. Prefer that name (shortening it to `offset_trf` for local variables). Backcompat for the old `transOffset` name is kept in most places by introducing a property alias. Started deprecating tight_bbox and tight_layout Recreated deprecated files and changed references Fix drawing animated artists changed in selector callback Fix getting tuple of animated artists; add comments and test Use list comprehension instead of filter Fix z_order Improve docstring and add comments Ensure log formatters use Unicode minus Fixes matplotlib#21540 FIX: better repr for subgridspecs FIX: add test for identical subgridspec FIX Use a fixture for widget test axes Improved coverage of mathtext and removed unused code Removed dev from 3.10-version DOC: explain too many ticks DOC: artist extent Update doc/users/faq/howto_faq.rst Co-authored-by: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com> Apply suggestions from code review Co-authored-by: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com> FIX: streamline examples DOC: add new example Update doc/users/faq/howto_faq.rst Co-authored-by: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com> Apply suggestions from code review Co-authored-by: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com> FIX: macosx check case-insensitive app name Only check for "python" case insensitive to match either Python or pythonw. Fix typo in `axhline` docstring Removed unused variables etc. Passed on sides and pad_to Use standard toolbar in wx. The previous approach manually positioned the toolbar to have it at the bottom of the window, but this can in fact be achieved just with style=wx.TB_BOTTOM. Removing manual sizing of the toolbar also fixes a bug previously present on Windows, whereby a `set_size_inches` reducing the size of the canvas would *not* reduce the window width, likely because it was forced to its max value by the toolbar's explicit size. Expire axes_grid1/axisartist deprecations. Clean up 3d plot box_aspect zooming linting Cleanup Make zoom and dist private attrs Deprecate Axes3D.dist Deprecate Axes3D.dist DOC: Fix upstream URL for merge in CircleCI DOC: Add hatch API to reference DOC: Document default cap styles - remove '(default)' from cap style demo as this is only true for Line2D and the default rcParameters - document default cap styles for Line2D and Patch in their cap style setters - document default cap style for GraphicsContextBase in the same way as it's already done for joinstyle Factor out underline-thickness lookups in mathtext. Just adding a small helper function. Fix merge Update _formlayout.py Bump minimum NumPy to 1.19 Fix name typo in API changes DOC: git:// is deprecated. See https://github.blog/2021-09-01-improving-git-protocol-security-github/ Today is a brownout day. I removed the sentence that git:// is RO and https:// is RW as you soon won't be able to use git:// Personally I use https:// as RO and ssh:// as RW, but I understand it might not be convenient on windows. Stop sorting artists in Figure Options dialog With matplotlib#18216, the order that artists are added to an Axes is their canonical order. The dialog should not be sorting them in some other manner. Additionally, this fixes a bug in that `apply_callback` indexes back to the original list, which means that changes will be made to the *wrong* artist if sorting actually occurred. It also makes the legend almost entirely wrong as well. See https://discourse.matplotlib.org/t/bug-on-re-generate-automatic-legend-of-matplotlib-figure-property/22511 Document ArtistList DOC: Document default join style in the same way as the default cap styles. Jointly track x and y in PolygonSelector. It's easier to track them in a single list. Also init _selection_artist and _polygon_handles with empty arrays, as there's no reason to pretend that they start with 0, 0. On the other hand, _xys does need to start as a non-empty array as the last point gets updated as being the cursor position. Verify that lib/src is not changed on -doc backports ci: Use released version to build v*-doc branches Fix typo in `tutorials/intermediate/arranging_axes.py` Trivial doc fix to annotations tutorial. Initially I just wanted to capitalize "matplotlib", but the wording was a bit awkward too, so... ENH: implement and use base layout_engine for more flexible layout. FIX: typo Remove some unnecessary getattrs. Figures always have a canvas attached (even if it's just a FigureCanvasBase), and canvases always have a "manager" attribute (which may be None). Canvases also always have a "toolbar" attribute (which also may be None). Altogether this allows avoiding a couple of getattrs. FIX: Return value instead of enum in get_capstyle/_joinstyle for MarkerStyle and Patch (as do Line2D, Collections and GraphicsContextBase) (1) turn off the grid after creating colorbar axes (2) added a test Cleanup "anatomy of a figure" No visual change. Improve formatting of "Anatomy of a figure" - Adapt margins - Reduce figure border width (still thick but not massive) - fontfamily: make code monospace - slightly move annotations to better places Run wheel builds on PRs when requested by a label Fix typos Deprecate cleared kwarg to get_renderer. This makes it easier for to mock the agg backend (e.g., in mplcairo). Note that this is anyways only a shorthand for calling a method (`.clear()`) on the renderer itself, so just issuing that call is just as simple, more explicit, and can be done even when one just has access to the renderer and not to the canvas (an admittedly rather hypothetical case). Improve ft2font error reporting. This prints out human-readable error messages for failures. As an example, `FT2Font("setup.py")` now raises ``` RuntimeError: In FT2Font: Can not load face (unknown file format; error code 0x2) ``` Ensure that all toolbar (old/new) subclasses can be init'ed consistently i.e. with the same signature: with `canvas` as sole arg for the old-style toolbars, with `toolmanager` as sole arg for the new ones. Subclasses that explicitly support setting a parent widget keep that support (except for gtk, which stashed that in the `.win` attribute but never used it), but that argument is always optional now; the default is the canvas' parent. The goal is to later replace all _get_toolbar implementations by a simple call (always with the same signature (dependent on the value of rcParams["toolbar"])) to the correct class in the FigureManagerBase constructor. DOC: More capitalization of Axes In line with matplotlib#18726. Triggered by matplotlib#22242. Started deprecating afm, fontconfig_pattern, and type1font Recreated deprecated files and changed references DOC: add dropdown DOC: add dropdown Fix topbar DOC: Add all the releases Just last point releases before 3.0 DOC: update release_guide DOC: rename versions [skip azp] [skip appveyor] [skip actions] BLD: pin sphinx data theme [skip actions] [skip appveyor] [skip azp] Add some tests for minspan{x,y} in RectangleSelector Skip tests on the -doc branches DOC: fix version switcher json [skip actions] [skip appveyor] [skip azp] DOC: fix version switcher [skip actions] [skip appveyor] [skip azp] FIX Fix Qt enum access. This was missed in the global fixing of enums for PyQt6 (now using _enum everywhere). To trigger, try to interactively save a figure but input an invalid format, e.g. "foo.bar". MNT: deprecate filled parameter to colorbar The *filled* kwarg doesn't directly do anything and filling is completely controlled by the mappable. OTOH, maybe we want to reinstate the ability of *filled* to fill contours? Deprecate colorbar.draw_all. Merge main and "other" params docs in colorbar.make_axes. `colorbar.make_axes` (and `make_axes_gridspec`) are low-level enough that it's not worth the complexity in docstring interpolation to split out "main" parameters and "other" parameters, when the docstring of the more commonly used `plt.colorbar` smashes them together. (Also, `pad` is not really much more low-level than `shrink` or `aspect`...) Numpydocify _colormap_kw_doc and use it in Colorbar too. Specify the focal length for 3d plots Create a gallery example showing the different proj_type options Typo Test fix, example fix, and linting What's new, example fix Merge conflict Offset zooming of focal length Code review comments, consolidate projection functions Try and fix zooming Try to fix the focal length zooming Update example Cleanup example cleanup more example tweaks more example tweak swap plot order Enforce a positive focal length focal lentgh tests flake8 linting docstring tweak Code review changes Make focal_length a private attr linting More code review changes and tests Additional code review changes Disalbe showing cursor data on a QuadMesh by default Give the Tk toolbar buttons a flat look Simplify FontProperties.copy(). Expanded documentation of Axis.set_ticks as per discussion in issue matplotlib#22262 (matplotlib#22270) * Expanded documentation of Axis.set_ticks() * Fix flake8 W293 (blank line contains whitespace) warnings * Expanded the documentation even more based on discussion in issue matplotlib#22262 * Update lib/matplotlib/axis.py - @jklymak rewording Co-authored-by: Jody Klymak <jklymak@gmail.com> * Reduced verbosity of doc by @jklymak 's suggestion. * On second thought, the previous wording could be seen as very ambiguous. * Update set_ticks docstring by @timhoffm compromise suggestion Co-authored-by: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com> * Removed extra sentence as per @timhoffm review * Blank line whitespace issue crept up again * Update lib/matplotlib/axis.py as per correction by @timhoffm Co-authored-by: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com> Co-authored-by: unknown <> Co-authored-by: Jody Klymak <jklymak@gmail.com> Co-authored-by: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com> MNT: make colorbars locators and formatters properties TST: test setters and getters in colorbar DOC: improve crosslinking for docs FIX: small fixes DOC: fix property docstrings FIX: minorformatter None Removed unused code Fixed repr for SecondaryAxis and increase coverage for axes/_base.py Apply suggestions from code review Co-authored-by: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com> Display bad format string in error message. I had something like `for i in range(n): plot(..., f"oC{i}")` which works for n up to 10, but for greater values one gets "oC10" which is not supported (which is reasonable, as some single-digit strings are actually *marker* abbreviations); mentioning the full format string in the error message ("Unrecognized character 0 in format string 'oC10'") makes it clearer. FIX: bury import of matplotlib.font_manager We need to ensure that the sub-module matplotlib.font_manager is imported when it is used in SclarFormater, however if we import it at the top level we will get circular imports. closes matplotlib#22305 In mpl_toolkits, use the same floating point slop as for standard ticks. Standard ticks use _interval_contains_close (in Axis._update_ticks); do the same in mpl_toolkits and deprecate the custom slops delta1, delta2 (if such knobs are really needed, we should try to have the same API in the main library anyways). FIX: use window_extent instead Add set_cursor method to FigureCanvasTk Don't warn on grid removal deprecation is grid is hidden Fixes matplotlib#21723. See matplotlib#21723 (comment) for a full desciption of motivation and edge cases. Modify example for x-axis tick labels at the top Primarily describe how to do this for a single Axes (using `tick_params`). Only mention the `rcParams` in a note. Globally changing `rcParams` is usually not a good idea and should not be demonstrated. The whole topic of `rcParams` (global, context, matplotlibrc) is too long to be discussed here and not the focus of the example. Remove Axes sublist modification from docs Make bar of pie example more explicit ... by saving and using the results from Axes method calls. Also, replace the colour palette in the bar chart. Respect `position` argument in Tk toolmanager Set focus properly to ensure mouse events get delivered to Tk canvas Rework/fix Text layout cache. Instead of caching the text layout based on a bunch of properties, only cache the computation of the text's metrics, which 1) should be the most expensive part (everything else in _get_layout is relatively simple iteration and arithmetic) and 2) depends on fewer implicit parameters. In fact, the old cache key was insufficient in that it would conflate usetex and non-usetex strings together, even though they have different metrics; e.g. with the (extremely artificial) example ```python figtext(.1, .5, "foo\nbar", size=32) # (0) figtext(.1, .5, "foo\nbar", usetex=True, size=32, c="r", alpha=.5) # (1) figtext(.3, .5, "foo\nbar", usetex=True, size=32, c="r", alpha=.5) # (2) ``` the linespacing of the first usetex string (1) would be "wrong": it is bigger that the one of the second usetex string (2), because it instead reuses the layout computed for the non-usetex string (0). The motivation is also to in the future let the renderer have better control on cache invalidation (with a yet-to-be-added renderer method), e.g. multiple instances of the same renderer cache could share the same layout info. Rename outdated seaborn styles. They are kept available under a versioned name for backcompat. dangling clf Silently discard blits if bbox is outside canvas Custom cap widths in box and whisker plots in bxp() and boxplot() Add pre-commit config and dev instructions Update pre-commit hooks rst format Disable autofixes on PRs Unless manually triggered. See https://pre-commit.ci/#configuration add pre-commit to environment.yml Slow down autoupdate schedule alphabetize Add sentence about where pre-commit config is Add excludes to pre-commit config Otherwise end of lines of test images will get fixed, this also ignores all the prev_whats_new and prev_api_changes as well as vendored components (agg, gitwash) pre-comit config CI: ban coverage 6.3 that may be causing random hangs in fork test
PR Summary
Expanded documentation of
Axis.set_ticks
as per discussion in #22262 to help protect future users from pitfalls when trying to add special/custom ticks.PR Checklist
Tests and Styling
pytest
passes).flake8-docstrings
and runflake8 --docstring-convention=all
).Documentation
doc/users/next_whats_new/
(follow instructions in README.rst there).doc/api/next_api_changes/
(follow instructions in README.rst there).