@@ -168,11 +168,8 @@ def set_title(self, label, fontdict=None, loc=None, pad=None, *, y=None,
168
168
Other keyword arguments are text properties, see `.Text` for a list
169
169
of valid text properties.
170
170
"""
171
- if loc is None :
172
- loc = mpl .rcParams ['axes.titlelocation' ]
173
-
174
- if y is None :
175
- y = mpl .rcParams ['axes.titley' ]
171
+ loc = mpl ._val_or_rc (loc , 'axes.titlelocation' ).lower ()
172
+ y = mpl ._val_or_rc (y , 'axes.titley' )
176
173
if y is None :
177
174
y = 1.0
178
175
else :
@@ -182,18 +179,16 @@ def set_title(self, label, fontdict=None, loc=None, pad=None, *, y=None,
182
179
titles = {'left' : self ._left_title ,
183
180
'center' : self .title ,
184
181
'right' : self ._right_title }
185
- title = _api .check_getitem (titles , loc = loc . lower () )
182
+ title = _api .check_getitem (titles , loc = loc )
186
183
default = {
187
184
'fontsize' : mpl .rcParams ['axes.titlesize' ],
188
185
'fontweight' : mpl .rcParams ['axes.titleweight' ],
189
186
'verticalalignment' : 'baseline' ,
190
- 'horizontalalignment' : loc . lower () }
187
+ 'horizontalalignment' : loc }
191
188
titlecolor = mpl .rcParams ['axes.titlecolor' ]
192
189
if not cbook ._str_lower_equal (titlecolor , 'auto' ):
193
190
default ["color" ] = titlecolor
194
- if pad is None :
195
- pad = mpl .rcParams ['axes.titlepad' ]
196
- self ._set_title_offset_trans (float (pad ))
191
+ self ._set_title_offset_trans (float (mpl ._val_or_rc (pad , 'axes.titlepad' )))
197
192
title .set_text (label )
198
193
title .update (default )
199
194
if fontdict is not None :
@@ -3160,8 +3155,7 @@ def stem(self, *args, linefmt=None, markerfmt=None, basefmt=None, bottom=0,
3160
3155
markerfmt = "o"
3161
3156
if markerfmt == '' :
3162
3157
markerfmt = ' ' # = empty line style; '' would resolve rcParams
3163
- markerstyle , markermarker , markercolor = \
3164
- _process_plot_format (markerfmt )
3158
+ markerstyle , markermarker , markercolor = _process_plot_format (markerfmt )
3165
3159
if markermarker is None :
3166
3160
markermarker = 'o'
3167
3161
if markerstyle is None :
@@ -3176,8 +3170,7 @@ def stem(self, *args, linefmt=None, markerfmt=None, basefmt=None, bottom=0,
3176
3170
basestyle , basemarker , basecolor = _process_plot_format (basefmt )
3177
3171
3178
3172
# New behaviour in 3.1 is to use a LineCollection for the stemlines
3179
- if linestyle is None :
3180
- linestyle = mpl .rcParams ['lines.linestyle' ]
3173
+ linestyle = mpl ._val_or_rc (linestyle , 'lines.linestyle' )
3181
3174
xlines = self .vlines if orientation == "vertical" else self .hlines
3182
3175
stemlines = xlines (
3183
3176
locs , bottom , heads ,
@@ -3745,8 +3738,7 @@ def _upcast_err(err):
3745
3738
3746
3739
# Make the style dict for caps (the "hats").
3747
3740
eb_cap_style = {** base_style , 'linestyle' : 'none' }
3748
- if capsize is None :
3749
- capsize = mpl .rcParams ["errorbar.capsize" ]
3741
+ capsize = mpl ._val_or_rc (capsize , "errorbar.capsize" )
3750
3742
if capsize > 0 :
3751
3743
eb_cap_style ['markersize' ] = 2. * capsize
3752
3744
if capthick is not None :
@@ -4100,27 +4092,18 @@ def boxplot(self, x, notch=None, sym=None, vert=None,
4100
4092
"""
4101
4093
4102
4094
# Missing arguments default to rcParams.
4103
- if whis is None :
4104
- whis = mpl .rcParams ['boxplot.whiskers' ]
4105
- if bootstrap is None :
4106
- bootstrap = mpl .rcParams ['boxplot.bootstrap' ]
4095
+ whis = mpl ._val_or_rc (whis , 'boxplot.whiskers' )
4096
+ bootstrap = mpl ._val_or_rc (bootstrap , 'boxplot.bootstrap' )
4107
4097
4108
4098
bxpstats = cbook .boxplot_stats (x , whis = whis , bootstrap = bootstrap ,
4109
4099
labels = tick_labels , autorange = autorange )
4110
- if notch is None :
4111
- notch = mpl .rcParams ['boxplot.notch' ]
4112
- if patch_artist is None :
4113
- patch_artist = mpl .rcParams ['boxplot.patchartist' ]
4114
- if meanline is None :
4115
- meanline = mpl .rcParams ['boxplot.meanline' ]
4116
- if showmeans is None :
4117
- showmeans = mpl .rcParams ['boxplot.showmeans' ]
4118
- if showcaps is None :
4119
- showcaps = mpl .rcParams ['boxplot.showcaps' ]
4120
- if showbox is None :
4121
- showbox = mpl .rcParams ['boxplot.showbox' ]
4122
- if showfliers is None :
4123
- showfliers = mpl .rcParams ['boxplot.showfliers' ]
4100
+ notch = mpl ._val_or_rc (notch , 'boxplot.notch' )
4101
+ patch_artist = mpl ._val_or_rc (patch_artist , 'boxplot.patchartist' )
4102
+ meanline = mpl ._val_or_rc (meanline , 'boxplot.meanline' )
4103
+ showmeans = mpl ._val_or_rc (showmeans , 'boxplot.showmeans' )
4104
+ showcaps = mpl ._val_or_rc (showcaps , 'boxplot.showcaps' )
4105
+ showbox = mpl ._val_or_rc (showbox , 'boxplot.showbox' )
4106
+ showfliers = mpl ._val_or_rc (showfliers , 'boxplot.showfliers' )
4124
4107
4125
4108
if boxprops is None :
4126
4109
boxprops = {}
@@ -4931,8 +4914,7 @@ def scatter(self, x, y, s=None, c=None, marker=None, cmap=None, norm=None,
4931
4914
scales = s # Renamed for readability below.
4932
4915
4933
4916
# load default marker from rcParams
4934
- if marker is None :
4935
- marker = mpl .rcParams ['scatter.marker' ]
4917
+ marker = mpl ._val_or_rc (marker , 'scatter.marker' )
4936
4918
4937
4919
if isinstance (marker , mmarkers .MarkerStyle ):
4938
4920
marker_obj = marker
@@ -6478,9 +6460,7 @@ def pcolormesh(self, *args, alpha=None, norm=None, cmap=None, vmin=None,
6478
6460
`~.Axes.pcolormesh`, which is not available with `~.Axes.pcolor`.
6479
6461
6480
6462
"""
6481
- if shading is None :
6482
- shading = mpl .rcParams ['pcolor.shading' ]
6483
- shading = shading .lower ()
6463
+ shading = mpl ._val_or_rc (shading , 'pcolor.shading' ).lower ()
6484
6464
kwargs .setdefault ('edgecolors' , 'none' )
6485
6465
6486
6466
X , Y , C , shading = self ._pcolorargs ('pcolormesh' , * args ,
@@ -6985,8 +6965,7 @@ def hist(self, x, bins=None, range=None, density=False, weights=None,
6985
6965
if np .isscalar (x ):
6986
6966
x = [x ]
6987
6967
6988
- if bins is None :
6989
- bins = mpl .rcParams ['hist.bins' ]
6968
+ bins = mpl ._val_or_rc (bins , 'hist.bins' )
6990
6969
6991
6970
# Validate string inputs here to avoid cluttering subsequent code.
6992
6971
_api .check_in_list (['bar' , 'barstacked' , 'step' , 'stepfilled' ],
0 commit comments