8000 test for shared log axes · matplotlib/matplotlib@9ca7b19 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9ca7b19

Browse files
committed
test for shared log axes
1 parent b20420f commit 9ca7b19

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

lib/matplotlib/tests/test_axes.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,25 @@ def test_autoscale_tight():
176176
assert_allclose(ax.get_xlim(), (-0.15, 3.15))
177177
assert_allclose(ax.get_ylim(), (1.0, 4.0))
178178

179+
180+
@cleanup(style='default')
181+
def test_autoscale_log_shared():
182+
# related to github #7587
183+
# array starts at zero to trigger _minpos handling
184+
x = np.arange(100, dtype=float)
185+
fig, (ax1, ax2) = plt.subplots(2, 1, sharex=True)
186+
ax1.loglog(x, x)
187+
ax2.semilogx(x, x)
188+
ax1.autoscale(tight=True)
189+
ax2.autoscale(tight=True)
190+
plt.draw()
191+
lims = (x[1], x[-1])
192+
assert_allclose(ax1.get_xlim(), lims)
193+
assert_allclose(ax1.get_ylim(), lims)
194+
assert_allclose(ax2.get_xlim(), lims)
195+
assert_allclose(ax2.get_ylim(), (x[0], x[-1]))
196+
197+
179198
@cleanup(style='default')
180199
def test_use_sticky_edges():
181200
fig, ax = plt.subplots()

lib/matplotlib/ticker.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2305,11 +2305,11 @@ def nonsingular(self, vmin, vmax):
23052305
# so for now we use 1 - minpos as a substitute.
23062306

23072307
if vmin <= 0:
2308-
vmin = max(minpos, vmin)
2309-
if vmax >= 0:
2310-
vmax = min(1 - minpos, vmax)
2308+
vmin = minpos
2309+
if vmax >= 1:
2310+
vmax = 1 - minpos
23112311
if vmin == vmax:
2312-
return 0.1 * vmin, 10 * vmin
2312+
return 0.1 * vmin, 1 - 0.1 * vmin
23132313

23142314
return vmin, vmax
23152315

0 commit comments

Comments
 (0)
0