Skip to content

Commit

Permalink
Fix matplotlib#5281: Include ticks in tight bounding box
Browse files Browse the repository at this point in the history
  • Loading branch information
mdboom committed Nov 17, 2015
1 parent f924f39 commit 4534759
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions lib/matplotlib/axis.py
Expand Up @@ -1049,7 +1049,6 @@ def _get_tick_bboxes(self, ticks, renderer):
Given the list of ticks, return two lists of bboxes. One for
tick lable1's and another for tick label2's.
"""

ticklabelBoxes = []
ticklabelBoxes2 = []

Expand All @@ -1065,7 +1064,7 @@ def _get_tick_bboxes(self, ticks, renderer):
def get_tightbbox(self, renderer):
"""
Return a bounding box that encloses the axis. It only accounts
tick labels, axis label, and offsetText.
tick labels, axis label, offsetText and ticks.
"""
if not self.get_visible():
return
Expand All @@ -1088,6 +1087,10 @@ def get_tightbbox(self, renderer):
bb.extend(ticklabelBoxes)
bb.extend(ticklabelBoxes2)

bb.extend(
tick._get_tick2line().get_window_extent(renderer)
for tick in ticks_to_draw)

bb = [b for b in bb if b.width != 0 or b.height != 0]
if bb:
_bbox = mtransforms.Bbox.union(bb)
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/lines.py
Expand Up @@ -568,7 +568,7 @@ def get_window_extent(self, renderer):
ignore=True)
# correct for marker size, if any
if self._marker:
ms = (self._markersize / 72.0 * self.figure.dpi) * 0.5
ms = (self._markersize / 72.0 * self.figure.dpi)
bbox = bbox.padded(ms)
return bbox

Expand Down

0 comments on commit 4534759

Please sign in to comment.