Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 929bffb

Browse files
committed
Don't draw axis (spines, ticks, labels) twice when using parasite axes.
We can just defer to the superclass' draw (axes._base.Axes.draw) which will correctly draw everything in get_children(); axislines.Axes.get_children already adds the axislines and gridlines to the superclass' get_children(). Likewise, get_tightbbox() doesn't need to be overridden because the superclass' get_tightbbox by default uses get_default_bbox_extra_artists, which fetches all visible children. (This point is not needed for the bugfix, but we may as well...) Don't bother using remove_text in the new figures, because that doesn't remove the labels anyways (and the tests are also about label placement).
1 parent 4769f7b commit 929bffb

10 files changed

Lines changed: 11 additions & 26 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
axes_grid1 and axisartist Axes no longer draw spines twice
2+
``````````````````````````````````````````````````````````
3+
4+
Previously, spines of `axes_grid1` and `axisartist` Axes would be drawn twice,
5+
leading to a "bold" appearance. This is no longer the case.

doc/users/whats_new.rst

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@ revision, see the :ref:`github-stats`.
1515
For a release, add a new section after this, then comment out the include
1616
and toctree below by indenting them. Uncomment them after the release.
1717
18-
.. include:: next_whats_new/README.rst
19-
.. toctree::
20-
:glob:
21-
:maxdepth: 1
18+
.. include:: next_whats_new/README.rst
2219

23-
next_whats_new/*
20+
.. toctree::
21+
:glob:
22+
:maxdepth: 1
23+
24+
next_whats_new/*
2425

2526
Ability to scale axis by a fixed order of magnitude
2627
---------------------------------------------------

lib/mpl_toolkits/axisartist/axislines.py

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -651,34 +651,13 @@ def new_fixed_axis(self, loc, offset=None):
651651
)
652652
return axis
653653

654-
655654
def new_floating_axis(self, nth_coord, value, axis_direction="bottom"):
656655
gh = self.get_grid_helper()
657656
axis = gh.new_floating_axis(nth_coord, value,
658657
axis_direction=axis_direction,
659658
axes=self)
660659
return axis
661660

662-
def draw(self, renderer, inframe=False):
663-
if not self._axisline_on:
664-
super().draw(renderer, inframe)
665-
return
666-
orig_artists = self.artists
667-
self.artists = [
668-
*self.artists, *self._axislines.values(), self.gridlines]
669-
super().draw(renderer, inframe)
670-
self.artists = orig_artists
671-
672-
def get_tightbbox(self, renderer, call_axes_locator=True):
673-
bb0 = super().get_tightbbox(renderer, call_axes_locator)
674-
if not self._axisline_on:
675-
return bb0
676-
bb = [bb0] + [axisline.get_tightbbox(renderer)
677-
for axisline in self._axislines.values()
678-
if axisline.get_visible()]
679-
bbox = Bbox.union([b for b in bb if b and (b.width!=0 or b.height!=0)])
680-
return bbox
681-
682661

683662
Subplot = maxes.subplot_class_factory(Axes)
684663

-57 Bytes
Loading
184 Bytes
Loading
511 Bytes
Loading
558 Bytes
Loading
301 Bytes
Loading
510 Bytes
Loading
-325 Bytes
Loading

0 commit comments

Comments
 (0)