Skip to content

Commit 99dab89

Browse files
committed
Add test for shared GeoAxes zoom propagation
1 parent fadd917 commit 99dab89

2 files changed

Lines changed: 29 additions & 2 deletions

File tree

lib/cartopy/tests/mpl/test_axes.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,3 +154,29 @@ def test_geoaxes_set_boundary_clipping():
154154
transform=ax1.transAxes)
155155

156156
return fig
157+
158+
159+
def test_shared_axes_zoom_propagation():
160+
fig = plt.figure()
161+
proj = ccrs.PlateCarree()
162+
ax1 = fig.add_subplot(1, 2, 1, projection=proj)
163+
ax2 = fig.add_subplot(1, 2, 2, projection=proj,
164+
sharex=ax1, sharey=ax1)
165+
166+
ax1.set_global()
167+
ax2.set_global()
168+
ax1.coastlines()
169+
ax2.coastlines()
170+
171+
fig.draw_without_rendering()
172+
173+
ax1.set_xlim(-20, 20)
174+
ax1.set_ylim(-10, 10)
175+
176+
assert ax2.get_xlim() == (-20, 20)
177+
assert ax2.get_ylim() == (-10, 10)
178+
179+
fig.draw_without_rendering()
180+
181+
assert ax2.get_xlim() == (-20, 20)
182+
assert ax2.get_ylim() == (-10, 10)

lib/cartopy/tests/mpl/test_set_extent.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,10 @@ def test_view_lim_autoscaling():
150150

151151
def test_view_lim_default_global(tmp_path):
152152
ax = plt.axes(projection=ccrs.PlateCarree())
153-
# The view lim should be the default unit bbox until it is drawn.
153+
# viewLim is set to projection bounds in __clear.
154+
expected = np.array([[-180, -90], [180, 90]])
154155
assert_array_almost_equal(ax.viewLim.frozen().get_points(),
155-
[[0, 0], [1, 1]])
156+
expected)
156157
plt.savefig(tmp_path / 'view_lim_default_global.png')
157158
expected = np.array([[-180, -90], [180, 90]])
158159
assert_array_almost_equal(ax.viewLim.frozen().get_points(),

0 commit comments

Comments
 (0)