7
7
import numpy as np
8
8
from numpy import ma
9
9
10
+ import matplotlib as mpl
10
11
import matplotlib .category # Register category unit converter as side-effect.
11
12
import matplotlib .cbook as cbook
12
13
import matplotlib .collections as mcoll
29
30
import matplotlib .transforms as mtransforms
30
31
import matplotlib .tri as mtri
31
32
import matplotlib .units as munits
32
- from matplotlib import _api , _docstring , _preprocess_data , rcParams
33
+ from matplotlib import _api , _docstring , _preprocess_data
33
34
from matplotlib .axes ._base import (
34
35
_AxesBase , _TransformedBoundsLocator , _process_plot_format )
35
36
from matplotlib .axes ._secondary_axes import SecondaryAxis
@@ -136,10 +137,10 @@ def set_title(self, label, fontdict=None, loc=None, pad=None, *, y=None,
136
137
of valid text properties.
137
138
"""
138
139
if loc is None :
139
- loc = rcParams ['axes.titlelocation' ]
140
+ loc = mpl . rcParams ['axes.titlelocation' ]
140
141
141
142
if y is None :
142
- y = rcParams ['axes.titley' ]
143
+ y = mpl . rcParams ['axes.titley' ]
143
144
if y is None :
144
145
y = 1.0
145
146
else :
@@ -151,15 +152,15 @@ def set_title(self, label, fontdict=None, loc=None, pad=None, *, y=None,
151
152
'right' : self ._right_title }
152
153
title = _api .check_getitem (titles , loc = loc .lower ())
153
154
default = {
154
- 'fontsize' : rcParams ['axes.titlesize' ],
155
- 'fontweight' : rcParams ['axes.titleweight' ],
155
+ 'fontsize' : mpl . rcParams ['axes.titlesize' ],
156
+ 'fontweight' : mpl . rcParams ['axes.titleweight' ],
156
157
'verticalalignment' : 'baseline' ,
157
158
'horizontalalignment' : loc .lower ()}
158
- titlecolor = rcParams ['axes.titlecolor' ]
159
+ titlecolor = mpl . rcParams ['axes.titlecolor' ]
159
160
if not cbook ._str_lower_equal (titlecolor , 'auto' ):
160
161
default ["color" ] = titlecolor
161
162
if pad is None :
162
- pad = rcParams ['axes.titlepad' ]
163
+ pad = mpl . rcParams ['axes.titlepad' ]
163
164
self ._set_title_offset_trans (float (pad ))
164
165
title .set_text (label )
165
166
title .update (default )
@@ -2332,7 +2333,7 @@ def bar(self, x, height, width=0.8, bottom=None, *, align="center",
2332
2333
ezorder += 0.01
2333
2334
error_kw .setdefault ('zorder' , ezorder )
2334
2335
ecolor = kwargs .pop ('ecolor' , 'k' )
2335
- capsize = kwargs .pop ('capsize' , rcParams ["errorbar.capsize" ])
2336
+ capsize = kwargs .pop ('capsize' , mpl . rcParams ["errorbar.capsize" ])
2336
2337
error_kw .setdefault ('ecolor' , ecolor )
2337
2338
error_kw .setdefault ('capsize' , capsize )
2338
2339
@@ -2969,13 +2970,14 @@ def stem(self, *args, linefmt=None, markerfmt=None, basefmt=None, bottom=0,
2969
2970
# resolve baseline format
2970
2971
if basefmt is None :
2971
2972
basefmt = (args [2 ] if len (args ) > 2 else
2972
- "C2-" if rcParams ["_internal.classic_mode" ] else "C3-" )
2973
+ "C2-" if mpl .rcParams ["_internal.classic_mode" ] else
2974
+ "C3-" )
2973
2975
basestyle , basemarker , basecolor = _process_plot_format (basefmt )
2974
2976
2975
2977
# New behaviour in 3.1 is to use a LineCollection for the stemlines
2976
2978
if use_line_collection :
2977
2979
if linestyle is None :
2978
- linestyle = rcParams ['lines.linestyle' ]
2980
+ linestyle = mpl . rcParams ['lines.linestyle' ]
2979
2981
xlines = self .vlines if orientation == "vertical" else self .hlines
2980
2982
stemlines = xlines (
2981
2983
locs , bottom , heads ,
@@ -3209,7 +3211,7 @@ def get_next_color():
3209
3211
horizontalalignment = label_alignment_h ,
3210
3212
verticalalignment = label_alignment_v ,
3211
3213
rotation = label_rotation ,
3212
- size = rcParams ['xtick.labelsize' ])
3214
+ size = mpl . rcParams ['xtick.labelsize' ])
3213
3215
t .set (** textprops )
3214
3216
texts .append (t )
3215
3217
@@ -3528,7 +3530,7 @@ def _upcast_err(err):
3528
3530
# Make the style dict for caps (the "hats").
3529
3531
eb_cap_style = {** base_style , 'linestyle' : 'none' }
3530
3532
if capsize is None :
3531
- capsize = rcParams ["errorbar.capsize" ]
3533
+ capsize = mpl . rcParams ["errorbar.capsize" ]
3532
3534
if capsize > 0 :
3533
3535
eb_cap_style ['markersize' ] = 2. * capsize
3534
3536
if capthick is not None :
@@ -3821,28 +3823,28 @@ def boxplot(self, x, notch=None, sym=None, vert=None, whis=None,
3821
3823
3822
3824
# Missing arguments default to rcParams.
3823
3825
if whis is None :
3824
- whis = rcParams ['boxplot.whiskers' ]
3826
+ whis = mpl . rcParams ['boxplot.whiskers' ]
3825
3827
if bootstrap is None :
3826
- bootstrap = rcParams ['boxplot.bootstrap' ]
3828
+ bootstrap = mpl . rcParams ['boxplot.bootstrap' ]
3827
3829
3828
3830
bxpstats = cbook .boxplot_stats (x , whis = whis , bootstrap = bootstrap ,
3829
3831
labels = labels , autorange = autorange )
3830
3832
if notch is None :
3831
- notch = rcParams ['boxplot.notch' ]
3833
+ notch = mpl . rcParams ['boxplot.notch' ]
3832
3834
if vert is None :
3833
- vert = rcParams ['boxplot.vertical' ]
3835
+ vert = mpl . rcParams ['boxplot.vertical' ]
3834
3836
if patch_artist is None :
3835
- patch_artist = rcParams ['boxplot.patchartist' ]
3837
+ patch_artist = mpl . rcParams ['boxplot.patchartist' ]
3836
3838
if meanline is None :
3837
- meanline = rcParams ['boxplot.meanline' ]
3839
+ meanline = mpl . rcParams ['boxplot.meanline' ]
3838
3840
if showmeans is None :
3839
- showmeans = rcParams ['boxplot.showmeans' ]
3841
+ showmeans = mpl . rcParams ['boxplot.showmeans' ]
3840
3842
if showcaps is None :
3841
- showcaps = rcParams ['boxplot.showcaps' ]
3843
+ showcaps = mpl . rcParams ['boxplot.showcaps' ]
3842
3844
if showbox is None :
3843
- showbox = rcParams ['boxplot.showbox' ]
3845
+ showbox = mpl . rcParams ['boxplot.showbox' ]
3844
3846
if showfliers is None :
3845
- showfliers = rcParams ['boxplot.showfliers' ]
3847
+ showfliers = mpl . rcParams ['boxplot.showfliers' ]
3846
3848
3847
3849
if boxprops is None :
3848
3850
boxprops = {}
@@ -4050,7 +4052,7 @@ def bxp(self, bxpstats, positions=None, widths=None, vert=True,
4050
4052
zdelta = 0.1
4051
4053
4052
4054
def merge_kw_rc (subkey , explicit , zdelta = 0 , usemarker = True ):
4053
- d = {k .split ('.' )[- 1 ]: v for k , v in rcParams .items ()
4055
+ d = {k .split ('.' )[- 1 ]: v for k , v in mpl . rcParams .items ()
4054
4056
if k .startswith (f'boxplot.{ subkey } props' )}
4055
4057
d ['zorder' ] = zorder + zdelta
4056
4058
if not usemarker :
@@ -4059,11 +4061,11 @@ def merge_kw_rc(subkey, explicit, zdelta=0, usemarker=True):
4059
4061
return d
4060
4062
4061
4063
box_kw = {
4062
- 'linestyle' : rcParams ['boxplot.boxprops.linestyle' ],
4063
- 'linewidth' : rcParams ['boxplot.boxprops.linewidth' ],
4064
- 'edgecolor' : rcParams ['boxplot.boxprops.color' ],
4065
- 'facecolor' : ('white' if rcParams ['_internal.classic_mode' ]
4066
- else rcParams ['patch.facecolor' ]),
4064
+ 'linestyle' : mpl . rcParams ['boxplot.boxprops.linestyle' ],
4065
+ 'linewidth' : mpl . rcParams ['boxplot.boxprops.linewidth' ],
4066
+ 'edgecolor' : mpl . rcParams ['boxplot.boxprops.color' ],
4067
+ 'facecolor' : ('white' if mpl . rcParams ['_internal.classic_mode' ]
4068
+ else mpl . rcParams ['patch.facecolor' ]),
4067
4069
'zorder' : zorder ,
4068
4070
** cbook .normalize_kwargs (boxprops , mpatches .PathPatch )
4069
4071
} if patch_artist else merge_kw_rc ('box' , boxprops , usemarker = False )
@@ -4300,13 +4302,13 @@ def _parse_scatter_color_args(c, edgecolors, kwargs, xsize,
4300
4302
if facecolors is None :
4301
4303
facecolors = kwcolor
4302
4304
4303
- if edgecolors is None and not rcParams ['_internal.classic_mode' ]:
4304
- edgecolors = rcParams ['scatter.edgecolors' ]
4305
+ if edgecolors is None and not mpl . rcParams ['_internal.classic_mode' ]:
4306
+ edgecolors = mpl . rcParams ['scatter.edgecolors' ]
4305
4307
4306
4308
c_was_none = c is None
4307
4309
if c is None :
4308
4310
c = (facecolors if facecolors is not None
4309
- else "b" if rcParams ['_internal.classic_mode' ]
4311
+ else "b" if mpl . rcParams ['_internal.classic_mode' ]
4310
4312
else get_next_color_func ())
4311
4313
c_is_string_or_strings = (
4312
4314
isinstance (c , str )
@@ -4498,8 +4500,8 @@ def scatter(self, x, y, s=None, c=None, marker=None, cmap=None, norm=None,
4498
4500
raise ValueError ("x and y must be the same size" )
4499
4501
4500
4502
if s is None :
4501
- s = (20 if rcParams ['_internal.classic_mode' ] else
4502
- rcParams ['lines.markersize' ] ** 2.0 )
4503
+ s = (20 if mpl . rcParams ['_internal.classic_mode' ] else
4504
+ mpl . rcParams ['lines.markersize' ] ** 2.0 )
4503
4505
s = np .ma .ravel (s )
4504
4506
if (len (s ) not in (1 , x .size ) or
4505
4507
(not np .issubdtype (s .dtype , np .floating ) and
@@ -4535,7 +4537,7 @@ def scatter(self, x, y, s=None, c=None, marker=None, cmap=None, norm=None,
4535
4537
4536
4538
# load default marker from rcParams
4537
4539
if marker is None :
4538
- marker = rcParams ['scatter.marker' ]
4540
+ marker = mpl . rcParams ['scatter.marker' ]
4539
4541
4540
4542
if isinstance (marker , mmarkers .MarkerStyle ):
4541
4543
marker_obj = marker
@@ -4576,10 +4578,10 @@ def scatter(self, x, y, s=None, c=None, marker=None, cmap=None, norm=None,
4576
4578
edgecolors = 'face'
4577
4579
4578
4580
if linewidths is None :
4579
- linewidths = rcParams ['lines.linewidth' ]
4581
+ linewidths = mpl . rcParams ['lines.linewidth' ]
4580
4582
elif np .iterable (linewidths ):
4581
4583
linewidths = [
4582
- lw if lw is not None else rcParams ['lines.linewidth' ]
4584
+ lw if lw is not None else mpl . rcParams ['lines.linewidth' ]
4583
4585
for lw in linewidths ]
4584
4586
4585
4587
offsets = np .ma .column_stack ([x , y ])
@@ -4616,7 +4618,7 @@ def scatter(self, x, y, s=None, c=None, marker=None, cmap=None, norm=None,
4616
4618
# finite size of the symbols. In v2.x, margins
4617
4619
# are present by default, so we disable this
4618
4620
# scatter-specific override.
4619
- if rcParams ['_internal.classic_mode' ]:
4621
+ if mpl . rcParams ['_internal.classic_mode' ]:
4620
4622
if self ._xmargin < 0.05 and x .size > 0 :
4621
4623
self .set_xmargin (0.05 )
4622
4624
if self ._ymargin < 0.05 and x .size > 0 :
@@ -5216,7 +5218,7 @@ def _fill_between_x_or_y(
5216
5218
5217
5219
dep_dir = {"x" : "y" , "y" : "x" }[ind_dir ]
5218
5220
5219
- if not rcParams ["_internal.classic_mode" ]:
5221
+ if not mpl . rcParams ["_internal.classic_mode" ]:
5220
5222
kwargs = cbook .normalize_kwargs (kwargs , mcoll .Collection )
5221
5223
if not any (c in kwargs for c in ("color" , "facecolor" )):
5222
5224
kwargs ["facecolor" ] = \
@@ -5546,7 +5548,7 @@ def imshow(self, X, cmap=None, norm=None, aspect=None,
5546
5548
(unassociated) alpha representation.
5547
5549
"""
5548
5550
if aspect is None :
5549
- aspect = rcParams ['image.aspect' ]
5551
+ aspect = mpl . rcParams ['image.aspect' ]
5550
5552
self .set_aspect (aspect )
5551
5553
im = mimage .AxesImage (self , cmap = cmap , norm = norm ,
5552
5554
interpolation = interpolation , origin = origin ,
@@ -5846,7 +5848,7 @@ def pcolor(self, *args, shading=None, alpha=None, norm=None, cmap=None,
5846
5848
"""
5847
5849
5848
5850
if shading is None :
5849
- shading = rcParams ['pcolor.shading' ]
5851
+ shading = mpl . rcParams ['pcolor.shading' ]
5850
5852
shading = shading .lower ()
5851
5853
X , Y , C , shading = self ._pcolorargs ('pcolor' , * args , shading = shading ,
5852
5854
kwargs = kwargs )
@@ -6110,7 +6112,7 @@ def pcolormesh(self, *args, alpha=None, norm=None, cmap=None, vmin=None,
6110
6112
6111
6113
"""
6112
6114
if shading is None :
6113
- shading = rcParams ['pcolor.shading' ]
6115
+ shading = mpl . rcParams ['pcolor.shading' ]
6114
6116
shading = shading .lower ()
6115
6117
kwargs .setdefault ('edgecolors' , 'none' )
6116
6118
@@ -6120,7 +6122,7 @@ def pcolormesh(self, *args, alpha=None, norm=None, cmap=None, vmin=None,
6120
6122
# convert to one dimensional array
6121
6123
C = C .ravel ()
6122
6124
6123
- kwargs .setdefault ('snap' , rcParams ['pcolormesh.snap' ])
6125
+ kwargs .setdefault ('snap' , mpl . rcParams ['pcolormesh.snap' ])
6124
6126
6125
6127
collection = mcoll .QuadMesh (
6126
6128
coords , antialiased = antialiased , shading = shading ,
@@ -6588,7 +6590,7 @@ def hist(self, x, bins=None, range=None, density=False, weights=None,
6588
6590
x = [x ]
6589
6591
6590
6592
if bins is None :
6591
- bins = rcParams ['hist.bins' ]
6593
+ bins = mpl . rcParams ['hist.bins' ]
6592
6594
6593
6595
# Validate string inputs here to avoid cluttering subsequent code.
6594
6596
_api .check_in_list (['bar' , 'barstacked' , 'step' , 'stepfilled' ],
@@ -6715,7 +6717,7 @@ def hist(self, x, bins=None, range=None, density=False, weights=None,
6715
6717
if rwidth is not None :
6716
6718
dr = np .clip (rwidth , 0 , 1 )
6717
6719
elif (len (tops ) > 1 and
6718
- ((not stacked ) or rcParams ['_internal.classic_mode' ])):
6720
+ ((not stacked ) or mpl . rcParams ['_internal.classic_mode' ])):
6719
6721
dr = 0.8
6720
6722
else :
6721
6723
dr = 1.0
@@ -8111,7 +8113,7 @@ def violin(self, vpstats, positions=None, vert=True, widths=0.5,
8111
8113
line_ends = [[- 0.25 ], [0.25 ]] * np .array (widths ) + positions
8112
8114
8113
8115
# Colors.
8114
- if rcParams ['_internal.classic_mode' ]:
8116
+ if mpl . rcParams ['_internal.classic_mode' ]:
8115
8117
fillcolor = 'y'
8116
8118
linecolor = 'r'
8117
8119
else :
0 commit comments