Skip to content

Commit

Permalink
Include gridliner labels in tight bbox calculation
Browse files Browse the repository at this point in the history
Docstring fix

Pass renderer to _draw_gridliner, add preceding draw() post-process steps to get_tightbbox()

Ignore files generated by my vim plugin

Python 2 compatibility

No longer clear _gridliners
  • Loading branch information
lukelbd committed Mar 5, 2020
1 parent eb52ccb commit 825bbb7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ benchmarks/envs/
\#*
\.\#*
*.swp
.vimsession
.ipynb_checkpoints/
.idea/

Expand Down
19 changes: 19 additions & 0 deletions lib/cartopy/mpl/geoaxes.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,25 @@ def hold_limits(self, hold=True):
(self.ignore_existing_data_limits,
self._autoscaleXon, self._autoscaleYon) = other

def get_tightbbox(self, renderer, *args, **kwargs):
"""Draw gridliners so tight bounding box algorithm will
incorporate gridliner labels."""
# Matplotlib approaches this problem in the same way, by duplicating
# post-processing steps in both Axes.draw and Axes.get_tightbbox
if self.get_autoscale_on() and self.ignore_existing_data_limits:
self.autoscale_view()

if self.background_patch.reclip:
clipped_path = self.background_patch.orig_path.clip_to_bbox(
self.viewLim)
self.background_patch._path = clipped_path

self.apply_aspect()
for gl in self._gridliners:
gl._draw_gridliner(background_patch=self.background_patch,
renderer=renderer)
return super(GeoAxes, self).get_tightbbox(renderer, *args, **kwargs)

@matplotlib.artist.allow_rasterization
def draw(self, renderer=None, inframe=False):
"""
Expand Down

0 comments on commit 825bbb7

Please sign in to comment.