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

Commit93de426

Browse files
authored
Merge pull request#14916 from anntzer/morescalevalidation
Make kwargs names in scale.py not include the axis direction.
2 parents78bee0f +ea57339 commit93de426

File tree

9 files changed

+185
-163
lines changed

9 files changed

+185
-163
lines changed

‎doc/api/next_api_changes/deprecations.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,3 +184,18 @@ Debian 8 (2015, EOL 06/2020) and Ubuntu 14.04 (EOL 04/2019) were the
184184
last versions of Debian and Ubuntu to ship avconv. It remains possible
185185
to force the use of avconv by using the ffmpeg-based writers with
186186
:rc:`animation.ffmpeg_path` set to "avconv".
187+
188+
log/symlog scale base, ticks, and nonpos specification
189+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
190+
`~.Axes.semilogx`, `~.Axes.semilogy`, `~.Axes.loglog`, `.LogScale`, and
191+
`.SymmetricalLogScale` used to take keyword arguments that depends on the axis
192+
orientation ("basex" vs "basey", "subsx" vs "subsy", "nonposx" vs "nonposy");
193+
these parameter names are now deprecated in favor of "base", "subs",
194+
"nonpositive". This deprecation also affects e.g. ``ax.set_yscale("log",
195+
basey=...)`` which must now be spelled ``ax.set_yscale("log", base=...)``.
196+
197+
The change from "nonpos" to "nonpositive" also affects `~.scale.LogTransform`,
198+
`~.scale.InvertedLogTransform`, `~.scale.SymmetricalLogTransform`, etc.
199+
200+
To use *different* bases for the x-axis and y-axis of a `~.Axes.loglog` plot,
201+
use e.g. ``ax.set_xscale("log", base=10); ax.set_yscale("log", base=2)``.

‎examples/scales/log_demo.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
ax2.grid()
2727

2828
# log x and y axis
29-
ax3.loglog(t,20*np.exp(-t/10.0),basex=2)
29+
ax3.loglog(t,20*np.exp(-t/10.0))
30+
ax3.set_xscale('log',base=2)
3031
ax3.set(title='loglog base 2 on x')
3132
ax3.grid()
3233

@@ -35,8 +36,8 @@
3536
x=10.0**np.linspace(0.0,2.0,20)
3637
y=x**2.0
3738

38-
ax4.set_xscale("log",nonposx='clip')
39-
ax4.set_yscale("log",nonposy='clip')
39+
ax4.set_xscale("log",nonpositive='clip')
40+
ax4.set_yscale("log",nonpositive='clip')
4041
ax4.set(title='Errorbars go negative')
4142
ax4.errorbar(x,y,xerr=0.1*x,yerr=5.0+0.75*y)
4243
# ylim must be set after errorbar to allow errorbar to autoscale limits

‎examples/scales/scales.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
# symmetric log
4646
ax=axs[1,1]
4747
ax.plot(x,y-y.mean())
48-
ax.set_yscale('symlog',linthreshy=0.02)
48+
ax.set_yscale('symlog',linthresh=0.02)
4949
ax.set_title('symlog')
5050
ax.grid(True)
5151

‎examples/scales/symlog_demo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
plt.subplot(313)
2828
plt.plot(x,np.sin(x/3.0))
2929
plt.xscale('symlog')
30-
plt.yscale('symlog',linthreshy=0.015)
30+
plt.yscale('symlog',linthresh=0.015)
3131
plt.grid(True)
3232
plt.ylabel('symlog both')
3333

‎lib/matplotlib/axes/_axes.py

Lines changed: 44 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1766,24 +1766,25 @@ def loglog(self, *args, **kwargs):
17661766
both the x-axis and the y-axis to log scaling. All of the concepts and
17671767
parameters of plot can be used here as well.
17681768
1769-
The additional parameters *basex/y*, *subsx/y* and *nonposx/y* control
1770-
the x/y-axis properties. They are just forwarded to `.Axes.set_xscale`
1771-
and `.Axes.set_yscale`.
1769+
The additional parameters *base*, *subs* and *nonpositive* control the
1770+
x/y-axis properties. They are just forwarded to `.Axes.set_xscale` and
1771+
`.Axes.set_yscale`. To use different properties on the x-axis and the
1772+
y-axis, use e.g.
1773+
``ax.set_xscale("log", base=10); ax.set_yscale("log", base=2)``.
17721774
17731775
Parameters
17741776
----------
1775-
basex, basey : float, default: 10
1776-
Base of thex/ylogarithm.
1777+
base : float, default: 10
1778+
Base of the logarithm.
17771779
1778-
subsx, subsy : sequence, optional
1779-
The location of the minor x/y ticks. If *None*, reasonable
1780-
locations are automatically chosen depending on the number of
1781-
decades in the plot.
1782-
See `.Axes.set_xscale` / `.Axes.set_yscale` for details.
1780+
subs : sequence, optional
1781+
The location of the minor ticks. If *None*, reasonable locations
1782+
are automatically chosen depending on the number of decades in the
1783+
plot. See `.Axes.set_xscale`/`.Axes.set_yscale` for details.
17831784
1784-
nonposx, nonposy : {'mask', 'clip'}, default: 'mask'
1785-
Non-positive valuesin x or ycan be masked as invalid, or clipped
1786-
to a verysmall positive number.
1785+
nonpositive : {'mask', 'clip'}, default: 'mask'
1786+
Non-positive values can be masked as invalid, or clipped to a very
1787+
small positive number.
17871788
17881789
Returns
17891790
-------
@@ -1795,16 +1796,16 @@ def loglog(self, *args, **kwargs):
17951796
**kwargs
17961797
All parameters supported by `.plot`.
17971798
"""
1798-
dx= {k:kwargs.pop(k)forkin ['basex','subsx','nonposx']
1799-
ifkinkwargs}
1800-
dy= {k:kwargs.pop(k)forkin ['basey','subsy','nonposy']
1801-
ifkinkwargs}
1802-
1799+
dx= {k:vfork,vinkwargs.items()
1800+
ifkin ['base','subs','nonpositive',
1801+
'basex','subsx','nonposx']}
18031802
self.set_xscale('log',**dx)
1803+
dy= {k:vfork,vinkwargs.items()
1804+
ifkin ['base','subs','nonpositive',
1805+
'basey','subsy','nonposy']}
18041806
self.set_yscale('log',**dy)
1805-
1806-
l=self.plot(*args,**kwargs)
1807-
returnl
1807+
returnself.plot(
1808+
*args,**{k:vfork,vinkwargs.items()ifknotin {*dx,*dy}})
18081809

18091810
# @_preprocess_data() # let 'plot' do the unpacking..
18101811
@docstring.dedent_interpd
@@ -1821,20 +1822,20 @@ def semilogx(self, *args, **kwargs):
18211822
the x-axis to log scaling. All of the concepts and parameters of plot
18221823
can be used here as well.
18231824
1824-
The additional parameters *basex*, *subsx* and *nonposx* control the
1825+
The additional parameters *base*, *subs*, and *nonpositive* control the
18251826
x-axis properties. They are just forwarded to `.Axes.set_xscale`.
18261827
18271828
Parameters
18281829
----------
1829-
basex : float, default: 10
1830+
base : float, default: 10
18301831
Base of the x logarithm.
18311832
1832-
subsx : array-like, optional
1833+
subs : array-like, optional
18331834
The location of the minor xticks. If *None*, reasonable locations
18341835
are automatically chosen depending on the number of decades in the
18351836
plot. See `.Axes.set_xscale` for details.
18361837
1837-
nonposx : {'mask', 'clip'}, default: 'mask'
1838+
nonpositive : {'mask', 'clip'}, default: 'mask'
18381839
Non-positive values in x can be masked as invalid, or clipped to a
18391840
very small positive number.
18401841
@@ -1848,12 +1849,12 @@ def semilogx(self, *args, **kwargs):
18481849
**kwargs
18491850
All parameters supported by `.plot`.
18501851
"""
1851-
d= {k:kwargs.pop(k)forkin ['basex','subsx','nonposx']
1852-
ifkinkwargs}
1853-
1852+
d= {k:vfork,vinkwargs.items()
1853+
ifkin['base','subs','nonpositive',
1854+
'basex','subsx','nonposx']}
18541855
self.set_xscale('log',**d)
1855-
l=self.plot(*args,**kwargs)
1856-
returnl
1856+
returnself.plot(
1857+
*args,**{k:vfork,vinkwargs.items()ifknotind})
18571858

18581859
# @_preprocess_data() # let 'plot' do the unpacking..
18591860
@docstring.dedent_interpd
@@ -1870,20 +1871,20 @@ def semilogy(self, *args, **kwargs):
18701871
the y-axis to log scaling. All of the concepts and parameters of plot
18711872
can be used here as well.
18721873
1873-
The additional parameters *basey*, *subsy* and *nonposy* control the
1874+
The additional parameters *base*, *subs*, and *nonpositive* control the
18741875
y-axis properties. They are just forwarded to `.Axes.set_yscale`.
18751876
18761877
Parameters
18771878
----------
1878-
basey : float, default: 10
1879+
base : float, default: 10
18791880
Base of the y logarithm.
18801881
1881-
subsy : array-like, optional
1882+
subs : array-like, optional
18821883
The location of the minor yticks. If *None*, reasonable locations
18831884
are automatically chosen depending on the number of decades in the
18841885
plot. See `.Axes.set_yscale` for details.
18851886
1886-
nonposy : {'mask', 'clip'}, default: 'mask'
1887+
nonpositive : {'mask', 'clip'}, default: 'mask'
18871888
Non-positive values in y can be masked as invalid, or clipped to a
18881889
very small positive number.
18891890
@@ -1897,12 +1898,12 @@ def semilogy(self, *args, **kwargs):
18971898
**kwargs
18981899
All parameters supported by `.plot`.
18991900
"""
1900-
d= {k:kwargs.pop(k)forkin ['basey','subsy','nonposy']
1901-
ifkinkwargs}
1901+
d= {k:vfork,vinkwargs.items()
1902+
ifkin ['base','subs','nonpositive',
1903+
'basey','subsy','nonposy']}
19021904
self.set_yscale('log',**d)
1903-
l=self.plot(*args,**kwargs)
1904-
1905-
returnl
1905+
returnself.plot(
1906+
*args,**{k:vfork,vinkwargs.items()ifknotind})
19061907

19071908
@_preprocess_data(replace_names=["x"],label_namer="x")
19081909
defacorr(self,x,**kwargs):
@@ -2343,11 +2344,11 @@ def bar(self, x, height, width=0.8, bottom=None, *, align="center",
23432344
iforientation=='vertical':
23442345
self._process_unit_info(xdata=x,ydata=height,kwargs=kwargs)
23452346
iflog:
2346-
self.set_yscale('log',nonposy='clip')
2347+
self.set_yscale('log',nonpositive='clip')
23472348
eliforientation=='horizontal':
23482349
self._process_unit_info(xdata=width,ydata=y,kwargs=kwargs)
23492350
iflog:
2350-
self.set_xscale('log',nonposx='clip')
2351+
self.set_xscale('log',nonpositive='clip')
23512352

23522353
# lets do some conversions now since some types cannot be
23532354
# subtracted uniformly
@@ -6792,9 +6793,9 @@ def hist(self, x, bins=None, range=None, density=False, weights=None,
67926793

67936794
iflog:
67946795
iforientation=='horizontal':
6795-
self.set_xscale('log',nonposx='clip')
6796+
self.set_xscale('log',nonpositive='clip')
67966797
else:# orientation == 'vertical'
6797-
self.set_yscale('log',nonposy='clip')
6798+
self.set_yscale('log',nonpositive='clip')
67986799

67996800
ifalign=='left':
68006801
x-=0.5*(bins[1]-bins[0])

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp