Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/mpl_toolkits/axisartist/axis_artist.py
Original file line number Diff line number Diff line change
Expand Up @@ -1086,7 +1086,7 @@ def get_tightbbox(self, renderer=None):
*self.minor_ticklabels.get_window_extents(renderer),
self.label.get_window_extent(renderer),
self.offsetText.get_window_extent(renderer),
self.line.get_window_extent(renderer),
self.line.get_tightbbox(renderer),
]
bb = [b for b in bb if b and (b.width != 0 or b.height != 0)]
if bb:
Expand Down
29 changes: 28 additions & 1 deletion lib/mpl_toolkits/axisartist/tests/test_axis_artist.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import numpy as np

import matplotlib as mpl
import matplotlib.pyplot as plt
from matplotlib.projections import PolarAxes
from matplotlib.testing.decorators import image_comparison
from matplotlib.transforms import Affine2D

from mpl_toolkits.axisartist import AxisArtistHelperRectlinear
from mpl_toolkits.axisartist import (AxisArtistHelperRectlinear, GridHelperCurveLinear,
HostAxes)
from mpl_toolkits.axisartist.axis_artist import (AxisArtist, AxisLabel,
LabelBase, Ticks, TickLabels)

Expand Down Expand Up @@ -90,3 +96,24 @@ def test_axis_artist():
axisline.label.set_pad(5)

ax.set_ylabel("Test")


@mpl.style.context('default')
def test_axisartist_tightbbox():
fig = plt.figure()
tr = Affine2D().scale(np.pi / 180., 1.) + PolarAxes.PolarTransform()
grid_helper = GridHelperCurveLinear(tr)
ax = fig.add_subplot(axes_class=HostAxes, grid_helper=grid_helper)
ax.axis["lon"] = ax.new_floating_axis(1, 9)

ax.set_xlim(-5, 12)
ax.set_ylim(-5, 10)

ax.axis['lon'].major_ticklabels.set_visible(False)

# Since the labels are invisible and the lines are clipped to the axes,
# the axis's tight bbox should be contained in the axes box.
renderer = fig._get_renderer()
tight_points = ax.axis['lon'].get_tightbbox(renderer).get_points()
for point in tight_points:
assert ax.bbox.contains(*point)
Loading