Skip to content

Commit

Permalink
FIX: contour sticky edges match dataLim (#2414)
Browse files Browse the repository at this point in the history
  • Loading branch information
rcomer authored Jul 11, 2024
1 parent ca2832e commit 11bb8d3
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions lib/cartopy/mpl/geoaxes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1594,16 +1594,21 @@ def contour(self, *args, **kwargs):
"""
result = super().contour(*args, **kwargs)

# We need to compute the dataLim correctly for contours.
if not _MPL_38:
# We need to compute the dataLim correctly for contours.
bboxes = [col.get_datalim(self.transData)
for col in result.collections
if col.get_paths()]
if bboxes:
extent = mtransforms.Bbox.union(bboxes)
self.update_datalim(extent.get_points())
else:
self.update_datalim(result.get_datalim(self.transData))
# We need to compute the dataLim correctly for contours and set the
# artist's sticky edges to match.
datalim = result.get_datalim(self.transData)
self.update_datalim(datalim)
result.sticky_edges.x[:] = datalim.xmin, datalim.xmax
result.sticky_edges.y[:] = datalim.ymin, datalim.ymax

self.autoscale_view()

Expand Down Expand Up @@ -1635,16 +1640,21 @@ def contourf(self, *args, **kwargs):
"""
result = super().contourf(*args, **kwargs)

# We need to compute the dataLim correctly for contours.
if not _MPL_38:
# We need to compute the dataLim correctly for contours.
bboxes = [col.get_datalim(self.transData)
for col in result.collections
if col.get_paths()]
if bboxes:
extent = mtransforms.Bbox.union(bboxes)
self.update_datalim(extent.get_points())
else:
self.update_datalim(result.get_datalim(self.transData))
# We need to compute the dataLim correctly for contours and set the
# artist's sticky edges to match.
datalim = result.get_datalim(self.transData)
self.update_datalim(datalim)
result.sticky_edges.x[:] = datalim.xmin, datalim.xmax
result.sticky_edges.y[:] = datalim.ymin, datalim.ymax

self.autoscale_view()

Expand Down

0 comments on commit 11bb8d3

Please sign in to comment.