Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cb21ba7

Browse files
authored
Merge pull request #7410 from efiring/log_locator_vmin
BUG: fix autoscale_view with log scale and margins
2 parents 263e675 + 1ae616e commit cb21ba7

27 files changed

+16
-1
lines changed
Loading
Loading

lib/matplotlib/tests/test_axes.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4667,6 +4667,21 @@ def test_fillbetween_cycle():
46674667
assert tuple(cc.get_edgecolors().squeeze()) == tuple(edge_target)
46684668

46694669

4670+
@cleanup
4671+
def test_log_margins():
4672+
plt.rcParams['axes.autolimit_mode'] = 'data'
4673+
fig, ax = plt.subplots()
4674+
margin = 0.05
4675+
ax.set_xmargin(margin)
4676+
ax.semilogx([1, 10], [1, 10])
4677+
xlim0, xlim1 = ax.get_xlim()
4678+
transform = ax.xaxis.get_transform()
4679+
xlim0t, xlim1t = transform.transform([xlim0, xlim1])
4680+
x0t, x1t = transform.transform([1, 10])
4681+
delta = (x1t - x0t) * margin
4682+
assert_allclose([xlim0t + delta, xlim1t - delta], [x0t, x1t])
4683+
4684+
46704685
if __name__ == '__main__':
46714686
import nose
46724687
import sys

lib/matplotlib/ticker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1912,7 +1912,7 @@ def view_limits(self, vmin, vmax):
19121912
"Data has no positive values, and therefore can not be "
19131913
"log-scaled.")
19141914

1915-
if vmin <= minpos:
1915+
if vmin <= 0:
19161916
vmin = minpos
19171917

19181918
if rcParams['axes.autolimit_mode'] == 'round_numbers':

0 commit comments

Comments
 (0)