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

Commite0415f9

Browse files
authored
Merge pull request#8836 from dstansby/log-mask
Mask invalid values by default when setting log scale
2 parents30cdd23 +a002f96 commite0415f9

File tree

7 files changed

+100
-73
lines changed

7 files changed

+100
-73
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Default behavior of log scales changed to mask <= 0 values
2+
``````````````````````````````````````````````````````````
3+
4+
Calling `matplotlib.axes.Axes.set_xscale` or `matplotlib.axes.Axes.set_yscale`
5+
now uses 'mask' as the default method to handle invalid values (as opposed to
6+
'clip'). This means that any values <= 0 on a log scale will not be shown.
7+
8+
Previously they were clipped to a very small number and shown.

‎lib/matplotlib/axes/_axes.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1618,7 +1618,6 @@ def semilogx(self, *args, **kwargs):
16181618
self.cla()
16191619
d= {'basex':kwargs.pop('basex',10),
16201620
'subsx':kwargs.pop('subsx',None),
1621-
'nonposx':kwargs.pop('nonposx','mask'),
16221621
}
16231622

16241623
self.set_xscale('log',**d)
@@ -1669,7 +1668,6 @@ def semilogy(self, *args, **kwargs):
16691668
self.cla()
16701669
d= {'basey':kwargs.pop('basey',10),
16711670
'subsy':kwargs.pop('subsy',None),
1672-
'nonposy':kwargs.pop('nonposy','mask'),
16731671
}
16741672
self.set_yscale('log',**d)
16751673
b=self._hold
@@ -2793,6 +2791,10 @@ def errorbar(self, x, y, yerr=None, xerr=None,
27932791
27942792
%(Line2D)s
27952793
2794+
Notes
2795+
-----
2796+
Error bars with negative values will not be shown when plotted on a
2797+
logarithmic axis.
27962798
"""
27972799
kwargs=cbook.normalize_kwargs(kwargs,_alias_map)
27982800
# anything that comes in as 'None', drop so the default thing

‎lib/matplotlib/axes/_base.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2961,10 +2961,10 @@ def set_xscale(self, value, **kwargs):
29612961
29622962
matplotlib.scale.LogisticTransform : logit transform
29632963
"""
2964-
# If the scale is being set to log,clip nonposx to prevent headaches
2964+
# If the scale is being set to log,mask nonposx to prevent headaches
29652965
# around zero
29662966
ifvalue.lower()=='log'and'nonposx'notinkwargs:
2967-
kwargs['nonposx']='clip'
2967+
kwargs['nonposx']='mask'
29682968

29692969
g=self.get_shared_x_axes()
29702970
foraxing.get_siblings(self):
@@ -3255,10 +3255,10 @@ def set_yscale(self, value, **kwargs):
32553255
32563256
matplotlib.scale.LogisticTransform : logit transform
32573257
"""
3258-
# If the scale is being set to log,clip nonposy to prevent headaches
3258+
# If the scale is being set to log,mask nonposy to prevent headaches
32593259
# around zero
32603260
ifvalue.lower()=='log'and'nonposy'notinkwargs:
3261-
kwargs['nonposy']='clip'
3261+
kwargs['nonposy']='mask'
32623262

32633263
g=self.get_shared_y_axes()
32643264
foraxing.get_siblings(self):

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp