Skip to content

Commit e9e90a9

Browse files
Fixes for projections that don't report axes bounds
correctly (geographic projections).
1 parent daccf92 commit e9e90a9

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

matplotview/_view_axes.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,12 @@ def draw(self, renderer: RendererBase):
4949

5050
# Check and see if the passed limiting box and extents of the
5151
# artist intersect, if not don't bother drawing this artist.
52-
if(Bbox.intersection(full_extents, self._clip_box) is not None):
52+
# First 2 checks are a special case where we received a bad clip box.
53+
# (those can happen when we try to get the bounds of a map projection)
54+
if(
55+
self._clip_box.width == 0 or self._clip_box.height == 0 or
56+
Bbox.intersection(full_extents, self._clip_box) is not None
57+
):
5358
self._artist.draw(self._renderer)
5459

5560
# Re-enable the clip box... and clip path...

matplotview/tests/test_inset_zoom.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,3 +155,29 @@ def test_polar_view(fig_test, fig_ref):
155155
ax_r1.set_rmax(2)
156156
ax_r2.plot(theta, r)
157157
ax_r2.set_rmax(1)
158+
159+
@check_figures_equal()
160+
def test_map_projection_view(fig_test, fig_ref):
161+
x = np.linspace(-2.5, 2.5, 20)
162+
y = np.linspace(-1, 1, 20)
163+
circ_gen = lambda: plt.Circle((1.5, 0.25), 0.7, ec="black", fc="blue")
164+
165+
# Test case...
166+
ax_t1 = fig_test.add_subplot(1, 2, 1, projection="hammer")
167+
ax_t2 = fig_test.add_subplot(1, 2, 2, projection="lambert")
168+
ax_t1.grid(True)
169+
ax_t2.grid(True)
170+
ax_t1.plot(x, y)
171+
ax_t1.add_patch(circ_gen())
172+
view(ax_t2, ax_t1)
173+
ax_t2.set_linescaling(False)
174+
175+
# Reference...
176+
ax_r1 = fig_ref.add_subplot(1, 2, 1, projection="hammer")
177+
ax_r2 = fig_ref.add_subplot(1, 2, 2, projection="lambert")
178+
ax_r1.grid(True)
179+
ax_r2.grid(True)
180+
ax_r1.plot(x, y)
181+
ax_r1.add_patch(circ_gen())
182+
ax_r2.plot(x, y)
183+
ax_r2.add_patch(circ_gen())

0 commit comments

Comments
 (0)