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 )
@@ -2330,7 +2331,7 @@ def bar(self, x, height, width=0.8, bottom=None, *, align="center",
2330
2331
ezorder += 0.01
2331
2332
error_kw .setdefault ('zorder' , ezorder )
2332
2333
ecolor = kwargs .pop ('ecolor' , 'k' )
2333
- capsize = kwargs .pop ('capsize' , rcParams ["errorbar.capsize" ])
2334
+ capsize = kwargs .pop ('capsize' , mpl . rcParams ["errorbar.capsize" ])
2334
2335
error_kw .setdefault ('ecolor' , ecolor )
2335
2336
error_kw .setdefault ('capsize' , capsize )
2336
2337
@@ -2967,13 +2968,14 @@ def stem(self, *args, linefmt=None, markerfmt=None, basefmt=None, bottom=0,
2967
2968
# resolve baseline format
2968
2969
if basefmt is None :
2969
2970
basefmt = (args [2 ] if len (args ) > 2 else
2970
- "C2-" if rcParams ["_internal.classic_mode" ] else "C3-" )
2971
+ "C2-" if mpl .rcParams ["_internal.classic_mode" ] else
2972
+ "C3-" )
2971
2973
basestyle , basemarker , basecolor = _process_plot_format (basefmt )
2972
2974
2973
2975
# New behaviour in 3.1 is to use a LineCollection for the stemlines
2974
2976
if use_line_collection :
2975
2977
if linestyle is None :
2976
- linestyle = rcParams ['lines.linestyle' ]
2978
+ linestyle = mpl . rcParams ['lines.linestyle' ]
2977
2979
xlines = self .vlines if orientation == "vertical" else self .hlines
2978
2980
stemlines = xlines (
2979
2981
locs , bottom , heads ,
@@ -3207,7 +3209,7 @@ def get_next_color():
3207
3209
horizontalalignment = label_alignment_h ,
3208
3210
verticalalignment = label_alignment_v ,
3209
3211
rotation = label_rotation ,
3210
- size = rcParams ['xtick.labelsize' ])
3212
+ size = mpl . rcParams ['xtick.labelsize' ])
3211
3213
t .set (** textprops )
3212
3214
texts .append (t )
3213
3215
@@ -3526,7 +3528,7 @@ def _upcast_err(err):
3526
3528
# Make the style dict for caps (the "hats").
3527
3529
eb_cap_style = {** base_style , 'linestyle' : 'none' }
3528
3530
if capsize is None :
3529
- capsize = rcParams ["errorbar.capsize" ]
3531
+ capsize = mpl . rcParams ["errorbar.capsize" ]
3530
3532
if capsize > 0 :
3531
3533
eb_cap_style ['markersize' ] = 2. * capsize
3532
3534
if capthick is not None :
@@ -3819,28 +3821,28 @@ def boxplot(self, x, notch=None, sym=None, vert=None, whis=None,
3819
3821
3820
3822
# Missing arguments default to rcParams.
3821
3823
if whis is None :
3822
- whis = rcParams ['boxplot.whiskers' ]
3824
+ whis = mpl . rcParams ['boxplot.whiskers' ]
3823
3825
if bootstrap is None :
3824
- bootstrap = rcParams ['boxplot.bootstrap' ]
3826
+ bootstrap = mpl . rcParams ['boxplot.bootstrap' ]
3825
3827
3826
3828
bxpstats = cbook .boxplot_stats (x , whis = whis , bootstrap = bootstrap ,
3827
3829
labels = labels , autorange = autorange )
3828
3830
if notch is None :
3829
- notch = rcParams ['boxplot.notch' ]
3831
+ notch = mpl . rcParams ['boxplot.notch' ]
3830
3832
if vert is None :
3831
- vert = rcParams ['boxplot.vertical' ]
3833
+ vert = mpl . rcParams ['boxplot.vertical' ]
3832
3834
if patch_artist is None :
3833
- patch_artist = rcParams ['boxplot.patchartist' ]
3835
+ patch_artist = mpl . rcParams ['boxplot.patchartist' ]
3834
3836
if meanline is None :
3835
- meanline = rcParams ['boxplot.meanline' ]
3837
+ meanline = mpl . rcParams ['boxplot.meanline' ]
3836
3838
if showmeans is None :
3837
- showmeans = rcParams ['boxplot.showmeans' ]
3839
+ showmeans = mpl . rcParams ['boxplot.showmeans' ]
3838
3840
if showcaps is None :
3839
- showcaps = rcParams ['boxplot.showcaps' ]
3841
+ showcaps = mpl . rcParams ['boxplot.showcaps' ]
3840
3842
if showbox is None :
3841
- showbox = rcParams ['boxplot.showbox' ]
3843
+ showbox = mpl . rcParams ['boxplot.showbox' ]
3842
3844
if showfliers is None :
3843
- showfliers = rcParams ['boxplot.showfliers' ]
3845
+ showfliers = mpl . rcParams ['boxplot.showfliers' ]
3844
3846
3845
3847
if boxprops is None :
3846
3848
boxprops = {}
@@ -4048,7 +4050,7 @@ def bxp(self, bxpstats, positions=None, widths=None, vert=True,
4048
4050
zdelta = 0.1
4049
4051
4050
4052
def merge_kw_rc (subkey , explicit , zdelta = 0 , usemarker = True ):
4051
- d = {k .split ('.' )[- 1 ]: v for k , v in rcParams .items ()
4053
+ d = {k .split ('.' )[- 1 ]: v for k , v in mpl . rcParams .items ()
4052
4054
if k .startswith (f'boxplot.{ subkey } props' )}
4053
4055
d ['zorder' ] = zorder + zdelta
4054
4056
if not usemarker :
@@ -4057,11 +4059,11 @@ def merge_kw_rc(subkey, explicit, zdelta=0, usemarker=True):
4057
4059
return d
4058
4060
4059
4061
box_kw = {
4060
- 'linestyle' : rcParams ['boxplot.boxprops.linestyle' ],
4061
- 'linewidth' : rcParams ['boxplot.boxprops.linewidth' ],
4062
- 'edgecolor' : rcParams ['boxplot.boxprops.color' ],
4063
- 'facecolor' : ('white' if rcParams ['_internal.classic_mode' ]
4064
- else rcParams ['patch.facecolor' ]),
4062
+ 'linestyle' : mpl . rcParams ['boxplot.boxprops.linestyle' ],
4063
+ 'linewidth' : mpl . rcParams ['boxplot.boxprops.linewidth' ],
4064
+ 'edgecolor' : mpl . rcParams ['boxplot.boxprops.color' ],
4065
+ 'facecolor' : ('white' if mpl . rcParams ['_internal.classic_mode' ]
4066
+ else mpl . rcParams ['patch.facecolor' ]),
4065
4067
'zorder' : zorder ,
4066
4068
** cbook .normalize_kwargs (boxprops , mpatches .PathPatch )
4067
4069
} if patch_artist else merge_kw_rc ('box' , boxprops , usemarker = False )
@@ -4298,13 +4300,13 @@ def _parse_scatter_color_args(c, edgecolors, kwargs, xsize,
4298
4300
if facecolors is None :
4299
4301
facecolors = kwcolor
4300
4302
4301
- if edgecolors is None and not rcParams ['_internal.classic_mode' ]:
4302
- edgecolors = rcParams ['scatter.edgecolors' ]
4303
+ if edgecolors is None and not mpl . rcParams ['_internal.classic_mode' ]:
4304
+ edgecolors = mpl . rcParams ['scatter.edgecolors' ]
4303
4305
4304
4306
c_was_none = c is None
4305
4307
if c is None :
4306
4308
c = (facecolors if facecolors is not None
4307
- else "b" if rcParams ['_internal.classic_mode' ]
4309
+ else "b" if mpl . rcParams ['_internal.classic_mode' ]
4308
4310
else get_next_color_func ())
4309
4311
c_is_string_or_strings = (
4310
4312
isinstance (c , str )
@@ -4496,8 +4498,8 @@ def scatter(self, x, y, s=None, c=None, marker=None, cmap=None, norm=None,
4496
4498
raise ValueError ("x and y must be the same size" )
4497
4499
4498
4500
if s is None :
4499
- s = (20 if rcParams ['_internal.classic_mode' ] else
4500
- rcParams ['lines.markersize' ] ** 2.0 )
4501
+ s = (20 if mpl . rcParams ['_internal.classic_mode' ] else
4502
+ mpl . rcParams ['lines.markersize' ] ** 2.0 )
4501
4503
s = np .ma .ravel (s )
4502
4504
if (len (s ) not in (1 , x .size ) or
4503
4505
(not np .issubdtype (s .dtype , np .floating ) and
@@ -4533,7 +4535,7 @@ def scatter(self, x, y, s=None, c=None, marker=None, cmap=None, norm=None,
4533
4535
4534
4536
# load default marker from rcParams
4535
4537
if marker is None :
4536
- marker = rcParams ['scatter.marker' ]
4538
+ marker = mpl . rcParams ['scatter.marker' ]
4537
4539
4538
4540
if isinstance (marker , mmarkers .MarkerStyle ):
4539
4541
marker_obj = marker
@@ -4574,10 +4576,10 @@ def scatter(self, x, y, s=None, c=None, marker=None, cmap=None, norm=None,
4574
4576
edgecolors = 'face'
4575
4577
4576
4578
if linewidths is None :
4577
- linewidths = rcParams ['lines.linewidth' ]
4579
+ linewidths = mpl . rcParams ['lines.linewidth' ]
4578
4580
elif np .iterable (linewidths ):
4579
4581
linewidths = [
4580
- lw if lw is not None else rcParams ['lines.linewidth' ]
4582
+ lw if lw is not None else mpl . rcParams ['lines.linewidth' ]
4581
4583
for lw in linewidths ]
4582
4584
4583
4585
offsets = np .ma .column_stack ([x , y ])
@@ -4614,7 +4616,7 @@ def scatter(self, x, y, s=None, c=None, marker=None, cmap=None, norm=None,
4614
4616
# finite size of the symbols. In v2.x, margins
4615
4617
# are present by default, so we disable this
4616
4618
# scatter-specific override.
4617
- if rcParams ['_internal.classic_mode' ]:
4619
+ if mpl . rcParams ['_internal.classic_mode' ]:
4618
4620
if self ._xmargin < 0.05 and x .size > 0 :
4619
4621
self .set_xmargin (0.05 )
4620
4622
if self ._ymargin < 0.05 and x .size > 0 :
@@ -5214,7 +5216,7 @@ def _fill_between_x_or_y(
5214
5216
5215
5217
dep_dir = {"x" : "y" , "y" : "x" }[ind_dir ]
5216
5218
5217
- if not rcParams ["_internal.classic_mode" ]:
5219
+ if not mpl . rcParams ["_internal.classic_mode" ]:
5218
5220
kwargs = cbook .normalize_kwargs (kwargs , mcoll .Collection )
5219
5221
if not any (c in kwargs for c in ("color" , "facecolor" )):
5220
5222
kwargs ["facecolor" ] = \
@@ -5544,7 +5546,7 @@ def imshow(self, X, cmap=None, norm=None, aspect=None,
5544
5546
(unassociated) alpha representation.
5545
5547
"""
5546
5548
if aspect is None :
5547
- aspect = rcParams ['image.aspect' ]
5549
+ aspect = mpl . rcParams ['image.aspect' ]
5548
5550
self .set_aspect (aspect )
5549
5551
im = mimage .AxesImage (self , cmap = cmap , norm = norm ,
5550
5552
interpolation = interpolation , origin = origin ,
@@ -5844,7 +5846,7 @@ def pcolor(self, *args, shading=None, alpha=None, norm=None, cmap=None,
5844
5846
"""
5845
5847
5846
5848
if shading is None :
5847
- shading = rcParams ['pcolor.shading' ]
5849
+ shading = mpl . rcParams ['pcolor.shading' ]
5848
5850
shading = shading .lower ()
5849
5851
X , Y , C , shading = self ._pcolorargs ('pcolor' , * args , shading = shading ,
5850
5852
kwargs = kwargs )
@@ -6108,7 +6110,7 @@ def pcolormesh(self, *args, alpha=None, norm=None, cmap=None, vmin=None,
6108
6110
6109
6111
"""
6110
6112
if shading is None :
6111
- shading = rcParams ['pcolor.shading' ]
6113
+ shading = mpl . rcParams ['pcolor.shading' ]
6112
6114
shading = shading .lower ()
6113
6115
kwargs .setdefault ('edgecolors' , 'none' )
6114
6116
@@ -6118,7 +6120,7 @@ def pcolormesh(self, *args, alpha=None, norm=None, cmap=None, vmin=None,
6118
6120
# convert to one dimensional array
6119
6121
C = C .ravel ()
6120
6122
6121
- kwargs .setdefault ('snap' , rcParams ['pcolormesh.snap' ])
6123
+ kwargs .setdefault ('snap' , mpl . rcParams ['pcolormesh.snap' ])
6122
6124
6123
6125
collection = mcoll .QuadMesh (
6124
6126
coords , antialiased = antialiased , shading = shading ,
@@ -6586,7 +6588,7 @@ def hist(self, x, bins=None, range=None, density=False, weights=None,
6586
6588
x = [x ]
6587
6589
6588
6590
if bins is None :
6589
- bins = rcParams ['hist.bins' ]
6591
+ bins = mpl . rcParams ['hist.bins' ]
6590
6592
6591
6593
# Validate string inputs here to avoid cluttering subsequent code.
6592
6594
_api .check_in_list (['bar' , 'barstacked' , 'step' , 'stepfilled' ],
@@ -6713,7 +6715,7 @@ def hist(self, x, bins=None, range=None, density=False, weights=None,
6713
6715
if rwidth is not None :
6714
6716
dr = np .clip (rwidth , 0 , 1 )
6715
6717
elif (len (tops ) > 1 and
6716
- ((not stacked ) or rcParams ['_internal.classic_mode' ])):
6718
+ ((not stacked ) or mpl . rcParams ['_internal.classic_mode' ])):
6717
6719
dr = 0.8
6718
6720
else :
6719
6721
dr = 1.0
@@ -8109,7 +8111,7 @@ def violin(self, vpstats, positions=None, vert=True, widths=0.5,
8109
8111
line_ends = [[- 0.25 ], [0.25 ]] * np .array (widths ) + positions
8110
8112
8111
8113
# Colors.
8112
- if rcParams ['_internal.classic_mode' ]:
8114
+ if mpl . rcParams ['_internal.classic_mode' ]:
8113
8115
fillcolor = 'y'
8114
8116
linecolor = 'r'
8115
8117
else :
0 commit comments