Skip to content

Commit 14c221d

Browse files
committed
Fix log scale for pcolor
1 parent 83c3ec8 commit 14c221d

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6252,8 +6252,7 @@ def pcolor(self, *args, shading=None, alpha=None, norm=None, cmap=None,
62526252
maxy = np.max(y)
62536253
collection.sticky_edges.x[:] = [minx, maxx]
62546254
collection.sticky_edges.y[:] = [miny, maxy]
6255-
corners = (minx, miny), (maxx, maxy)
6256-
self.update_datalim(corners)
6255+
self.update_datalim(coords.reshape(-1, 2))
62576256
self._request_autoscale_view()
62586257
return collection
62596258

lib/matplotlib/tests/test_axes.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1571,6 +1571,25 @@ def test_pcolor_datetime_axis():
15711571
label.set_rotation(30)
15721572

15731573

1574+
@check_figures_equal(extensions=["png"])
1575+
def test_pcolor_log_scale(fig_test, fig_ref):
1576+
"""
1577+
Check that setting a log scale sets good default axis limits
1578+
when using pcolor.
1579+
"""
1580+
x = np.linspace(0, 1, 11)
1581+
y = np.linspace(1, 2, 5)
1582+
X, Y = np.meshgrid(x, y)
1583+
C = X[:-1, :-1] + Y[:-1, :-1]
1584+
1585+
ax = fig_test.subplots()
1586+
ax.pcolor(X, Y, C)
1587+
ax.set_xscale('log')
1588+
1589+
ax = fig_ref.subplots()
1590+
ax.pcolor(X, Y, C)
1591+
ax.set_xlim(1e-1, 1e0)
1592+
ax.set_xscale('log')
15741593

15751594

15761595
def test_pcolorargs():

0 commit comments

Comments
 (0)