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

Appearance settings

Commit 041d4e0

Browse filesBrowse files
authored
Merge pull request #24555 from parthpankajtiwary/symlog-warn
ENH: Add warning for SymLogScale when values in linear scale range
2 parents fbfa28d + 6bc9f61 commit 041d4e0
Copy full SHA for 041d4e0

File tree

Expand file treeCollapse file tree

2 files changed

+19
-0
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+19
-0
lines changed

‎lib/matplotlib/scale.py

Copy file name to clipboardExpand all lines: lib/matplotlib/scale.py
+5Lines 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
def transform_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
with np.errstate(divide="ignore", invalid="ignore"):
393398
out = np.sign(a) * self.linthresh * (
394399
np.power(self.base,

‎lib/matplotlib/tests/test_scale.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_scale.py
+14Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,20 @@ def test_symlog_mask_nan():
5555
assert type(out) == type(x)
5656

5757

58+
def test_symlog_linthresh():
59+
np.random.seed(19680801)
60+
x = np.random.random(100)
61+
y = np.random.random(100)
62+
63+
fig, ax = plt.subplots()
64+
plt.plot(x, y, 'o')
65+
ax.set_xscale('symlog')
66+
ax.set_yscale('symlog')
67+
68+
with pytest.warns(UserWarning, match="All values .* of linthresh"):
69+
fig.canvas.draw()
70+
71+
5872
@image_comparison(['logit_scales.png'], remove_text=True)
5973
def test_logit_scales():
6074
fig, ax = plt.subplots()

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.