Skip to content

Combine Axes.{lines,images,collections,patches,text,tables} into single list #18216

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

Merged
merged 12 commits into from
Apr 2, 2021

Conversation

QuLogic
Copy link
Member

@QuLogic QuLogic commented Aug 11, 2020

PR Summary

This mostly fixes #17247; combining artists into a single list has several benefits to draw ordering. You can see some of the effects in the changed test images. For simplification, the default labels for artists will now be numbered by overall children count, instead of a type-specific count.

There are a few remaining lists, but they require additional work first, or can be ignored:

  • Axes.artists; this would fix inconsistencies in bxp, but breaks Colorbar as it relies on Axes.artists drawing last to produce its outline.
  • Axes.collections; changes streamplot slightly, and errorbar is now correctly drawn as a group. See commit message for exact details.
  • Axes.containers; appears to not be used in the draw tree, or anything at all, really? Maybe for legends only.
  • Axes.images
  • Axes.lines
  • Axes.patches
  • Axes.tables
  • Axes.texts

PR Checklist

  • Has Pytest style unit tests
  • Code is Flake 8 compliant
  • [n/a] New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • [n/a] Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/next_api_changes/* if API changed in a backward-incompatible way

@QuLogic QuLogic added this to the v3.4.0 milestone Aug 11, 2020
@dopplershift
Copy link
Contributor

dopplershift commented Aug 11, 2020

image

😱

For future reviewers, that line count is only because of changes to a couple of SVG files.

@tacaswell
Copy link
Member

I am 100% sure that this will break people who are relying on ax.lines.clear() to remove all of the lines. I suspect that if we are going to go this route we are going to have to return a list sub-class that warns a lot if you mutate it, but forwards those changes through as the opening pass. We can then see much much push back we get to either move to read-only / remove it.

I'm also a bit worried about relying on type checking to re-construct the old lists, but the docs strings do name the types so I think my worries would be placated by adding a warning to those methods if the artist is of a type that would not then show up in the list.

@jklymak
Copy link
Member

jklymak commented Aug 13, 2020

I am 100% sure that this will break people who are relying on ax.lines.clear()

So, should these lists ever have been made public in the first place? ax.lines.clear() is not going to delete the lines, it will just mean they are never drawn. Not quite sure how we move them to being private or immutable without causing a lot of breakage.

@QuLogic
Copy link
Member Author

QuLogic commented Aug 14, 2020

ax.lines.clear() is not going to delete the lines,

It is pretty close though, since Line2D._remove_method would be ax.lines.remove, and the remaining stuff in Artist.remove is mostly about staleness:

if self._remove_method is not None:
self._remove_method(self)
# clear stale callback
self.stale_callback = None
_ax_flag = False
if hasattr(self, 'axes') and self.axes:
# remove from the mouse hit list
self.axes._mouseover_set.discard(self)
# mark the axes as stale
self.axes.stale = True
# decouple the artist from the axes
self.axes = None
_ax_flag = True
if self.figure:
self.figure = None
if not _ax_flag:
self.figure = True

@QuLogic QuLogic force-pushed the combine-Axes-children branch from 1022fe9 to fc1f2ff Compare August 25, 2020 03:46
@QuLogic
Copy link
Member Author

QuLogic commented Aug 25, 2020

Now that #18320 is in, I can push the last step of merging Axes.artists. I'll work on the fancy list thing now.

@QuLogic
Copy link
Member Author

QuLogic commented Aug 25, 2020

Sigh, tests are fine, but doc examples trigger both self.blah.remove and self.blah.append.

@QuLogic QuLogic force-pushed the combine-Axes-children branch 2 times, most recently from 7e2ff00 to e445140 Compare August 27, 2020 02:10
@QuLogic QuLogic marked this pull request as ready for review August 27, 2020 02:36
@QuLogic
Copy link
Member Author

QuLogic commented Aug 27, 2020

I believe this is now fully working; several tests required small tweaks since things are now drawn more correctly. See the individual commit messages for further details.

Copy link
Contributor

@dopplershift dopplershift left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks pretty good to me. In addition to the question below: I think I actually like the old boxplot behavior of drawing the box edges over the whiskers slightly better. No way to easily preserve?

@QuLogic
Copy link
Member Author

QuLogic commented Aug 28, 2020

I think I actually like the old boxplot behavior of drawing the box edges over the whiskers slightly better. No way to easily preserve?

Much like the tests, we 'just' have to add the box edges to the plot later to do that. But note that this will mean that when using patch_artist=False (the default), the result will change (so there would be test result changes either way).

# these attributes don't even exist yet, in which case
# ``hasattr(ax, "_children")`` is necessary because this can be
# called very early in the axes init process (e.g., for twin axes)
# when these attributes don't even exist yet, in which case
# `get_children` would raise an AttributeError.
if self._xmargin and scalex and self._autoscaleXon:
x_stickies = np.sort(np.concatenate([
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find this 5 lines of code completely incomprehensible. having two for statements and an if statement in a list comprehension is too cute in my opinion.

@QuLogic QuLogic force-pushed the combine-Axes-children branch from e445140 to 8955aad Compare August 29, 2020 06:01
@QuLogic QuLogic force-pushed the combine-Axes-children branch from 8955aad to 7555896 Compare September 16, 2020 07:57
@tacaswell
Copy link
Member

We should note that doing ax.lines = [...] currently works (and I can imaging an defend-able use case for flipping between two sets of lines), however I do not think that this is worth the machinery to make work. I'm inclined to document this as something that is broken (and then re-address shimming it if it causes significant user pain).

@QuLogic QuLogic force-pushed the combine-Axes-children branch from 8308603 to b2e3f7e Compare October 10, 2020 04:15
Comment on lines +657 to +746
_tight = self._tight
if not _tight:
# if image data only just use the datalim
for artist in self._children:
if isinstance(artist, mimage.AxesImage):
_tight = True
elif isinstance(artist, (mlines.Line2D, mpatches.Patch)):
_tight = False
break
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
_tight = self._tight
if not _tight:
# if image data only just use the datalim
for artist in self._children:
if isinstance(artist, mimage.AxesImage):
_tight = True
elif isinstance(artist, (mlines.Line2D, mpatches.Patch)):
_tight = False
break
has_image = any(isinstance(c, mimage.AxesImage)
for c in self._children)
has_line_or_patch = any(isinstance(c, (mlines.Line2D, mpatches.Patch))
for c in self._children)
_tight = self._tight or (has_image and not has_line_or_patch)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trying to avoid iterating self._children twice here.

Copy link
Member

@timhoffm timhoffm Oct 13, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why? Optimization? - I don't think that's relevant, 'cause we usually don't have thousands of Artists. And if so, iterating twice through them is probably the least of our problems. Moreover, if performance is a real concern, have you profiled this? List comprehensions are better optimized in Python than equivalent for loops, so I wouldn't even know which solution is faster.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given the early exit condition of any the performance should be something measured/profiled. In the absence of that, we should go with clarity. It's not clear to me which of those that is.

Copy link
Member Author

@QuLogic QuLogic Oct 17, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I've done this correctly, I'm pretty certain that the single loop is faster than the comprehensions, whether the first condition exits early, the second does, or neither:

import timeit


class AxesImage: pass
class Line2D: pass
class Patch: pass
class Other: pass


def loop(_tight, children):
    if not _tight:
        # if image data only just use the datalim
        for artist in children:
            if isinstance(artist, AxesImage):
                _tight = True
            elif isinstance(artist, (Line2D, Patch)):
                _tight = False
                break
    return _tight


def comprehension(_tight, children):
    has_image = any(isinstance(c, AxesImage) for c in children)
    has_line_or_patch = any(isinstance(c, (Line2D, Patch))
                            for c in children)
    tight = _tight or (has_image and not has_line_or_patch)
    return tight


setup = 'from __main__ import AxesImage, Line2D, Patch, Other, children'

for N in [10, 100, 1000]:
    print('N =', N)
    children = [Other()] * N
    print('No early exit')
    print('loop',
          timeit.timeit('loop(False, children)', setup=f'{setup}, loop',
                        number=1000000))
    print('comprehension',
          timeit.timeit('comprehension(False, children)',
                        setup=f'{setup}, comprehension', number=1000000))

    children = [Other()] * N
    children[1] = AxesImage()
    print('First loop early exit')
    print('loop',
          timeit.timeit('loop(False, children)', setup=f'{setup}, loop',
                        number=1000000))
    print('comprehension',
          timeit.timeit('comprehension(False, children)',
                        setup=f'{setup}, comprehension', number=1000000))

    children = [Other()] * N
    children[-2] = AxesImage()
    print('First loop late exit')
    print('loop',
          timeit.timeit('loop(False, children)', setup=f'{setup}, loop',
                        number=1000000))
    print('comprehension',
          timeit.timeit('comprehension(False, children)',
                        setup=f'{setup}, comprehension', number=1000000))

    children = [Other()] * N
    children[1] = Line2D()
    print('Second loop early exit')
    print('loop',
          timeit.timeit('loop(False, children)', setup=f'{setup}, loop',
                        number=1000000))
    print('comprehension',
          timeit.timeit('comprehension(False, children)',
                        setup=f'{setup}, comprehension', number=1000000))

    children = [Other()] * N
    children[-2] = Line2D()
    print('Second loop late exit')
    print('loop',
          timeit.timeit('loop(False, children)', setup=f'{setup}, loop',
                        number=1000000))
    print('comprehension',
          timeit.timeit('comprehension(False, children)',
                        setup=f'{setup}, comprehension', number=1000000))

    print()
    print()

Figure_1
I don't expect people to have 1000 artists, but the order of 10-100 might be possible in 3D. Not having benchmarked the rest of the 3D code though, I don't know if this difference is particularly significant.


@property
def collections(self):
return self.ArtistList(self, 'collections', 'add_collection',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it be simpler to warn here and return a plain list compared to defining the ArtistList class?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's how it used to be before #18216 (comment)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough.

QuLogic added 12 commits April 1, 2021 19:12
The lines can still be accessed via a read-only property.
The patches can still be accessed via a read-only property, but now are
combined with lines for sorting and overall drawing purposes.
The texts can still be accessed via a read-only property, but now are
combined with lines and patches for sorting and drawing purposes.
The tables can still be accessed via a read-only property, but now are
combined with lines, patches and texts for sorting and drawing purposes.
The images can still be accessed via a read-only property, but now are
combined with lines, patches, tables and texts for sorting and drawing
purposes.
The collections can still be accessed via a read-only property, but now
are combined with images, lines, patches, tables and texts for sorting
and drawing purposes.

There was a quite a bit more fallout from this one:
* `streamplot` had to add the arrows after the line collection, so they
  would remain on top. Because `FancyArrowPatch` is created in display
  coordinates, this meant that their limits changed slightly, as adding
  the line collection would have re-adjusted the `Axes.transData`.
* The `test_pre_transform_plotting` image needed to be regenerated
  because of the above limit change. I took this opportunity to clean up
  some of the previous keep-image-the-same hacks.
* The `test_arrow_contains_point` test image now has 'contained' scatter
  points correctly over the arrows.
* Tests in `test_patches.py` needed to be re-ordered slightly as they
  were checking alpha between collections and non-collection artists.
* The `test_fancy` legend images needed to be regenerated because
  errorbars are correctly drawn as a group now.
Note, that the legend `test_fancy` test needed an ordering change
because legends handles are no longer grouped by type.
The artists can still be accessed via a read-only property, but now are
combined with collections, images, lines, patches, tables and texts for
sorting and drawing purposes.

Additionally, anything added using `Axes.add_artist` will now appear in
the correct type sublist, and may not appear in `Axes.artists` if it
matches any of the other lists.

There are two test image changes, both of which have to do with `bxp`
and its `patch_artist=True` option. This uses a `Patch` with
`Axes.add_artist` instead of `Axes.plot` and so used to appear in
different order. This change now makes `patch_artist=True` and
`path_artist=False` order the same way, since there's no special
grouping.
@QuLogic QuLogic force-pushed the combine-Axes-children branch from 1edcfe8 to 8737ac3 Compare April 1, 2021 23:23
@tacaswell
Copy link
Member

anyone can merge on CI green.

@tacaswell tacaswell merged commit 4085fc7 into matplotlib:master Apr 2, 2021
@QuLogic QuLogic deleted the combine-Axes-children branch April 5, 2021 21:13
@QuLogic QuLogic mentioned this pull request Apr 5, 2021
6 tasks
QuLogic added a commit to QuLogic/matplotlib that referenced this pull request Jan 12, 2022
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
stanleyjs added a commit to stanleyjs/matplotlib that referenced this pull request Jan 26, 2022
_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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Maintenance Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Move towards making Axes.lines, Axes.patches, ... read-only views of a single child list.
5 participants