Skip to content

Commit 83c3ec8

Browse files
committed
Make sure pcolormesh log limits are good
1 parent c887ecb commit 83c3ec8

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6481,8 +6481,7 @@ def pcolormesh(self, *args, alpha=None, norm=None, cmap=None, vmin=None,
64816481
maxx, maxy = np.max(coords, axis=0)
64826482
collection.sticky_edges.x[:] = [minx, maxx]
64836483
collection.sticky_edges.y[:] = [miny, maxy]
6484-
corners = (minx, miny), (maxx, maxy)
6485-
self.update_datalim(corners)
6484+
self.update_datalim(coords)
64866485
self._request_autoscale_view()
64876486
return collection
64886487

lib/matplotlib/tests/test_axes.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1497,6 +1497,27 @@ def test_pcolormesh_nearest_noargs(fig_test, fig_ref):
14971497
ax.pcolormesh(x, y, C, shading="nearest")
14981498

14991499

1500+
@check_figures_equal(extensions=["png"])
1501+
def test_pcolormesh_log_scale(fig_test, fig_ref):
1502+
"""
1503+
Check that setting a log scale sets good default axis limits
1504+
when using pcolormesh.
1505+
"""
1506+
x = np.linspace(0, 1, 11)
1507+
y = np.linspace(1, 2, 5)
1508+
X, Y = np.meshgrid(x, y)
1509+
C = X + Y
1510+
1511+
ax = fig_test.subplots()
1512+
ax.pcolormesh(X, Y, C)
1513+
ax.set_xscale('log')
1514+
1515+
ax = fig_ref.subplots()
1516+
ax.pcolormesh(X, Y, C)
1517+
ax.set_xlim(1e-2, 1e1)
1518+
ax.set_xscale('log')
1519+
1520+
15001521
@image_comparison(['pcolormesh_datetime_axis.png'], style='mpl20')
15011522
def test_pcolormesh_datetime_axis():
15021523
# Remove this line when this test image is regenerated.
@@ -1550,6 +1571,8 @@ def test_pcolor_datetime_axis():
15501571
label.set_rotation(30)
15511572

15521573

1574+
1575+
15531576
def test_pcolorargs():
15541577
n = 12
15551578
x = np.linspace(-1.5, 1.5, n)

0 commit comments

Comments
 (0)