-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Include outward ticks in bounding box #5683
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -169,6 +169,21 @@ def apply_tickdir(self, tickdir): | |
""" | ||
pass | ||
|
||
def get_tickdir(self): | ||
return self._tickdir | ||
|
||
def get_tick_padding(self): | ||
""" | ||
Get the length of the tick outside of the axes. | ||
""" | ||
tickdir = self._tickdir | ||
if tickdir == 'in': | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. bit of a bike shed, better to do this with a dictionary? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure. |
||
return 0.0 | ||
elif tickdir == 'inout': | ||
return self._size / 2 | ||
elif tickdir == 'out': | ||
return self._size | ||
|
||
def get_children(self): | ||
children = [self.tick1line, self.tick2line, | ||
self.gridline, self.label1, self.label2] | ||
|
@@ -349,13 +364,11 @@ def apply_tickdir(self, tickdir): | |
|
||
if self._tickdir == 'in': | ||
self._tickmarkers = (mlines.TICKUP, mlines.TICKDOWN) | ||
self._pad = self._base_pad | ||
elif self._tickdir == 'inout': | ||
self._tickmarkers = ('|', '|') | ||
self._pad = self._base_pad + self._size / 2. | ||
else: | ||
self._tickmarkers = (mlines.TICKDOWN, mlines.TICKUP) | ||
self._pad = self._base_pad + self._size | ||
self._pad = self._base_pad + self.get_tick_padding() | ||
self.stale = True | ||
|
||
def _get_text1(self): | ||
|
@@ -485,13 +498,11 @@ def apply_tickdir(self, tickdir): | |
|
||
if self._tickdir == 'in': | ||
self._tickmarkers = (mlines.TICKRIGHT, mlines.TICKLEFT) | ||
self._pad = self._base_pad | ||
elif self._tickdir == 'inout': | ||
self._tickmarkers = ('_', '_') | ||
self._pad = self._base_pad + self._size / 2. | ||
else: | ||
self._tickmarkers = (mlines.TICKLEFT, mlines.TICKRIGHT) | ||
self._pad = self._base_pad + self._size | ||
self._pad = self._base_pad + self.get_tick_padding() | ||
self.stale = True | ||
|
||
# how far from the y axis line the right of the ticklabel are | ||
|
@@ -1067,7 +1078,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 themselves. | ||
""" | ||
if not self.get_visible(): | ||
return | ||
|
@@ -1097,6 +1108,9 @@ def get_tightbbox(self, renderer): | |
else: | ||
return None | ||
|
||
def get_tick_padding(self): | ||
return self.majorTicks[0].get_tick_padding() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should this be Never underestimate pathological users.... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's a good point. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Another point: are we always guaranteed at least one tick? On Thu, Dec 17, 2015 at 11:59 AM, Michael Droettboom <
|
||
|
||
@allow_rasterization | ||
def draw(self, renderer, *args, **kwargs): | ||
'Draw the axis lines, grid lines, tick lines and labels' | ||
|
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.
Is this going to work for polar axes? I would also double-check that this doesn't utterly bork for axes3d (not that I'd expect it to work great there, just to not crash or something).
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.
polar axes don't have ticks -- but it does appear that this needs to be updated so it's aware of when the ticks are present or not.
It doesn't seem to crash for axes3d, though as you say, it doesn't really do the right thin other than add a bit more space.