Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit15571fc

Browse files
ENH: Add warning for SymLogScale when values in linear scale
1 parentfbfa28d commit15571fc

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

‎lib/matplotlib/scale.py‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,11 @@ def __init__(self, base, linthresh, linscale):
389389

390390
deftransform_non_affine(self,a):
391391
abs_a=np.abs(a)
392+
if (abs_a<self.linthresh).all():
393+
_api.warn_external(
394+
"All values for SymLogScale are below linthresh, making "
395+
"it effectively linear. You likely should lower the value "
396+
"of linthresh. ")
392397
withnp.errstate(divide="ignore",invalid="ignore"):
393398
out=np.sign(a)*self.linthresh* (
394399
np.power(self.base,

‎lib/matplotlib/tests/test_scale.py‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
importio
1515
importpytest
1616

17+
importrandom
18+
1719

1820
@check_figures_equal()
1921
deftest_log_scales(fig_test,fig_ref):
@@ -55,6 +57,25 @@ def test_symlog_mask_nan():
5557
asserttype(out)==type(x)
5658

5759

60+
deftest_symlog_linthresh():
61+
fig,ax=plt.subplots()
62+
63+
n_samples=100
64+
65+
upper_bound=1.0
66+
67+
x= [random.uniform(0.0,upper_bound)for_inrange(n_samples)]
68+
y= [random.uniform(0.0,upper_bound)for_inrange(n_samples)]
69+
70+
withpytest.warns(UserWarning)asrecord:
71+
plt.plot(x,y,'o')
72+
ax.set_xscale('symlog')
73+
ax.set_yscale('symlog')
74+
plt.show()
75+
76+
assertlen(record)==1
77+
78+
5879
@image_comparison(['logit_scales.png'],remove_text=True)
5980
deftest_logit_scales():
6081
fig,ax=plt.subplots()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp