77import numpy as np
88from numpy import ma
99
10+ import matplotlib as mpl
1011import matplotlib .category # Register category unit converter as side-effect.
1112import matplotlib .cbook as cbook
1213import matplotlib .collections as mcoll
2930import matplotlib .transforms as mtransforms
3031import matplotlib .tri as mtri
3132import matplotlib .units as munits
32- from matplotlib import _api , _docstring , _preprocess_data , rcParams
33+ from matplotlib import _api , _docstring , _preprocess_data
3334from matplotlib .axes ._base import (
3435 _AxesBase , _TransformedBoundsLocator , _process_plot_format )
3536from matplotlib .axes ._secondary_axes import SecondaryAxis
@@ -136,10 +137,10 @@ def set_title(self, label, fontdict=None, loc=None, pad=None, *, y=None,
136137 of valid text properties.
137138 """
138139 if loc is None :
139- loc = rcParams ['axes.titlelocation' ]
140+ loc = mpl . rcParams ['axes.titlelocation' ]
140141
141142 if y is None :
142- y = rcParams ['axes.titley' ]
143+ y = mpl . rcParams ['axes.titley' ]
143144 if y is None :
144145 y = 1.0
145146 else :
@@ -151,15 +152,15 @@ def set_title(self, label, fontdict=None, loc=None, pad=None, *, y=None,
151152 'right' : self ._right_title }
152153 title = _api .check_getitem (titles , loc = loc .lower ())
153154 default = {
154- 'fontsize' : rcParams ['axes.titlesize' ],
155- 'fontweight' : rcParams ['axes.titleweight' ],
155+ 'fontsize' : mpl . rcParams ['axes.titlesize' ],
156+ 'fontweight' : mpl . rcParams ['axes.titleweight' ],
156157 'verticalalignment' : 'baseline' ,
157158 'horizontalalignment' : loc .lower ()}
158- titlecolor = rcParams ['axes.titlecolor' ]
159+ titlecolor = mpl . rcParams ['axes.titlecolor' ]
159160 if not cbook ._str_lower_equal (titlecolor , 'auto' ):
160161 default ["color" ] = titlecolor
161162 if pad is None :
162- pad = rcParams ['axes.titlepad' ]
163+ pad = mpl . rcParams ['axes.titlepad' ]
163164 self ._set_title_offset_trans (float (pad ))
164165 title .set_text (label )
165166 title .update (default )
@@ -2330,7 +2331,7 @@ def bar(self, x, height, width=0.8, bottom=None, *, align="center",
23302331 ezorder += 0.01
23312332 error_kw .setdefault ('zorder' , ezorder )
23322333 ecolor = kwargs .pop ('ecolor' , 'k' )
2333- capsize = kwargs .pop ('capsize' , rcParams ["errorbar.capsize" ])
2334+ capsize = kwargs .pop ('capsize' , mpl . rcParams ["errorbar.capsize" ])
23342335 error_kw .setdefault ('ecolor' , ecolor )
23352336 error_kw .setdefault ('capsize' , capsize )
23362337
@@ -2967,13 +2968,14 @@ def stem(self, *args, linefmt=None, markerfmt=None, basefmt=None, bottom=0,
29672968 # resolve baseline format
29682969 if basefmt is None :
29692970 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-" )
29712973 basestyle , basemarker , basecolor = _process_plot_format (basefmt )
29722974
29732975 # New behaviour in 3.1 is to use a LineCollection for the stemlines
29742976 if use_line_collection :
29752977 if linestyle is None :
2976- linestyle = rcParams ['lines.linestyle' ]
2978+ linestyle = mpl . rcParams ['lines.linestyle' ]
29772979 xlines = self .vlines if orientation == "vertical" else self .hlines
29782980 stemlines = xlines (
29792981 locs , bottom , heads ,
@@ -3207,7 +3209,7 @@ def get_next_color():
32073209 horizontalalignment = label_alignment_h ,
32083210 verticalalignment = label_alignment_v ,
32093211 rotation = label_rotation ,
3210- size = rcParams ['xtick.labelsize' ])
3212+ size = mpl . rcParams ['xtick.labelsize' ])
32113213 t .set (** textprops )
32123214 texts .append (t )
32133215
@@ -3526,7 +3528,7 @@ def _upcast_err(err):
35263528 # Make the style dict for caps (the "hats").
35273529 eb_cap_style = {** base_style , 'linestyle' : 'none' }
35283530 if capsize is None :
3529- capsize = rcParams ["errorbar.capsize" ]
3531+ capsize = mpl . rcParams ["errorbar.capsize" ]
35303532 if capsize > 0 :
35313533 eb_cap_style ['markersize' ] = 2. * capsize
35323534 if capthick is not None :
@@ -3819,28 +3821,28 @@ def boxplot(self, x, notch=None, sym=None, vert=None, whis=None,
38193821
38203822 # Missing arguments default to rcParams.
38213823 if whis is None :
3822- whis = rcParams ['boxplot.whiskers' ]
3824+ whis = mpl . rcParams ['boxplot.whiskers' ]
38233825 if bootstrap is None :
3824- bootstrap = rcParams ['boxplot.bootstrap' ]
3826+ bootstrap = mpl . rcParams ['boxplot.bootstrap' ]
38253827
38263828 bxpstats = cbook .boxplot_stats (x , whis = whis , bootstrap = bootstrap ,
38273829 labels = labels , autorange = autorange )
38283830 if notch is None :
3829- notch = rcParams ['boxplot.notch' ]
3831+ notch = mpl . rcParams ['boxplot.notch' ]
38303832 if vert is None :
3831- vert = rcParams ['boxplot.vertical' ]
3833+ vert = mpl . rcParams ['boxplot.vertical' ]
38323834 if patch_artist is None :
3833- patch_artist = rcParams ['boxplot.patchartist' ]
3835+ patch_artist = mpl . rcParams ['boxplot.patchartist' ]
38343836 if meanline is None :
3835- meanline = rcParams ['boxplot.meanline' ]
3837+ meanline = mpl . rcParams ['boxplot.meanline' ]
38363838 if showmeans is None :
3837- showmeans = rcParams ['boxplot.showmeans' ]
3839+ showmeans = mpl . rcParams ['boxplot.showmeans' ]
38383840 if showcaps is None :
3839- showcaps = rcParams ['boxplot.showcaps' ]
3841+ showcaps = mpl . rcParams ['boxplot.showcaps' ]
38403842 if showbox is None :
3841- showbox = rcParams ['boxplot.showbox' ]
3843+ showbox = mpl . rcParams ['boxplot.showbox' ]
38423844 if showfliers is None :
3843- showfliers = rcParams ['boxplot.showfliers' ]
3845+ showfliers = mpl . rcParams ['boxplot.showfliers' ]
38443846
38453847 if boxprops is None :
38463848 boxprops = {}
@@ -4048,7 +4050,7 @@ def bxp(self, bxpstats, positions=None, widths=None, vert=True,
40484050 zdelta = 0.1
40494051
40504052 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 ()
40524054 if k .startswith (f'boxplot.{ subkey } props' )}
40534055 d ['zorder' ] = zorder + zdelta
40544056 if not usemarker :
@@ -4057,11 +4059,11 @@ def merge_kw_rc(subkey, explicit, zdelta=0, usemarker=True):
40574059 return d
40584060
40594061 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' ]),
40654067 'zorder' : zorder ,
40664068 ** cbook .normalize_kwargs (boxprops , mpatches .PathPatch )
40674069 } if patch_artist else merge_kw_rc ('box' , boxprops , usemarker = False )
@@ -4298,13 +4300,13 @@ def _parse_scatter_color_args(c, edgecolors, kwargs, xsize,
42984300 if facecolors is None :
42994301 facecolors = kwcolor
43004302
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' ]
43034305
43044306 c_was_none = c is None
43054307 if c is None :
43064308 c = (facecolors if facecolors is not None
4307- else "b" if rcParams ['_internal.classic_mode' ]
4309+ else "b" if mpl . rcParams ['_internal.classic_mode' ]
43084310 else get_next_color_func ())
43094311 c_is_string_or_strings = (
43104312 isinstance (c , str )
@@ -4496,8 +4498,8 @@ def scatter(self, x, y, s=None, c=None, marker=None, cmap=None, norm=None,
44964498 raise ValueError ("x and y must be the same size" )
44974499
44984500 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 )
45014503 s = np .ma .ravel (s )
45024504 if (len (s ) not in (1 , x .size ) or
45034505 (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,
45334535
45344536 # load default marker from rcParams
45354537 if marker is None :
4536- marker = rcParams ['scatter.marker' ]
4538+ marker = mpl . rcParams ['scatter.marker' ]
45374539
45384540 if isinstance (marker , mmarkers .MarkerStyle ):
45394541 marker_obj = marker
@@ -4574,10 +4576,10 @@ def scatter(self, x, y, s=None, c=None, marker=None, cmap=None, norm=None,
45744576 edgecolors = 'face'
45754577
45764578 if linewidths is None :
4577- linewidths = rcParams ['lines.linewidth' ]
4579+ linewidths = mpl . rcParams ['lines.linewidth' ]
45784580 elif np .iterable (linewidths ):
45794581 linewidths = [
4580- lw if lw is not None else rcParams ['lines.linewidth' ]
4582+ lw if lw is not None else mpl . rcParams ['lines.linewidth' ]
45814583 for lw in linewidths ]
45824584
45834585 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,
46144616 # finite size of the symbols. In v2.x, margins
46154617 # are present by default, so we disable this
46164618 # scatter-specific override.
4617- if rcParams ['_internal.classic_mode' ]:
4619+ if mpl . rcParams ['_internal.classic_mode' ]:
46184620 if self ._xmargin < 0.05 and x .size > 0 :
46194621 self .set_xmargin (0.05 )
46204622 if self ._ymargin < 0.05 and x .size > 0 :
@@ -5214,7 +5216,7 @@ def _fill_between_x_or_y(
52145216
52155217 dep_dir = {"x" : "y" , "y" : "x" }[ind_dir ]
52165218
5217- if not rcParams ["_internal.classic_mode" ]:
5219+ if not mpl . rcParams ["_internal.classic_mode" ]:
52185220 kwargs = cbook .normalize_kwargs (kwargs , mcoll .Collection )
52195221 if not any (c in kwargs for c in ("color" , "facecolor" )):
52205222 kwargs ["facecolor" ] = \
@@ -5544,7 +5546,7 @@ def imshow(self, X, cmap=None, norm=None, aspect=None,
55445546 (unassociated) alpha representation.
55455547 """
55465548 if aspect is None :
5547- aspect = rcParams ['image.aspect' ]
5549+ aspect = mpl . rcParams ['image.aspect' ]
55485550 self .set_aspect (aspect )
55495551 im = mimage .AxesImage (self , cmap = cmap , norm = norm ,
55505552 interpolation = interpolation , origin = origin ,
@@ -5844,7 +5846,7 @@ def pcolor(self, *args, shading=None, alpha=None, norm=None, cmap=None,
58445846 """
58455847
58465848 if shading is None :
5847- shading = rcParams ['pcolor.shading' ]
5849+ shading = mpl . rcParams ['pcolor.shading' ]
58485850 shading = shading .lower ()
58495851 X , Y , C , shading = self ._pcolorargs ('pcolor' , * args , shading = shading ,
58505852 kwargs = kwargs )
@@ -6108,7 +6110,7 @@ def pcolormesh(self, *args, alpha=None, norm=None, cmap=None, vmin=None,
61086110
61096111 """
61106112 if shading is None :
6111- shading = rcParams ['pcolor.shading' ]
6113+ shading = mpl . rcParams ['pcolor.shading' ]
61126114 shading = shading .lower ()
61136115 kwargs .setdefault ('edgecolors' , 'none' )
61146116
@@ -6118,7 +6120,7 @@ def pcolormesh(self, *args, alpha=None, norm=None, cmap=None, vmin=None,
61186120 # convert to one dimensional array
61196121 C = C .ravel ()
61206122
6121- kwargs .setdefault ('snap' , rcParams ['pcolormesh.snap' ])
6123+ kwargs .setdefault ('snap' , mpl . rcParams ['pcolormesh.snap' ])
61226124
61236125 collection = mcoll .QuadMesh (
61246126 coords , antialiased = antialiased , shading = shading ,
@@ -6586,7 +6588,7 @@ def hist(self, x, bins=None, range=None, density=False, weights=None,
65866588 x = [x ]
65876589
65886590 if bins is None :
6589- bins = rcParams ['hist.bins' ]
6591+ bins = mpl . rcParams ['hist.bins' ]
65906592
65916593 # Validate string inputs here to avoid cluttering subsequent code.
65926594 _api .check_in_list (['bar' , 'barstacked' , 'step' , 'stepfilled' ],
@@ -6713,7 +6715,7 @@ def hist(self, x, bins=None, range=None, density=False, weights=None,
67136715 if rwidth is not None :
67146716 dr = np .clip (rwidth , 0 , 1 )
67156717 elif (len (tops ) > 1 and
6716- ((not stacked ) or rcParams ['_internal.classic_mode' ])):
6718+ ((not stacked ) or mpl . rcParams ['_internal.classic_mode' ])):
67176719 dr = 0.8
67186720 else :
67196721 dr = 1.0
@@ -8109,7 +8111,7 @@ def violin(self, vpstats, positions=None, vert=True, widths=0.5,
81098111 line_ends = [[- 0.25 ], [0.25 ]] * np .array (widths ) + positions
81108112
81118113 # Colors.
8112- if rcParams ['_internal.classic_mode' ]:
8114+ if mpl . rcParams ['_internal.classic_mode' ]:
81138115 fillcolor = 'y'
81148116 linecolor = 'r'
81158117 else :
0 commit comments