168
168
import logging
169
169
import locale
170
170
import math
171
+
171
172
import numpy as np
172
- from matplotlib import rcParams
173
+
174
+ import matplotlib as mpl
173
175
from matplotlib import cbook
174
176
from matplotlib import transforms as mtransforms
175
177
@@ -291,7 +293,7 @@ def fix_minus(s):
291
293
:rc:`axes.unicode_minus`.
292
294
"""
293
295
return (s .replace ('-' , '\N{MINUS SIGN} ' )
294
- if rcParams ['axes.unicode_minus' ]
296
+ if mpl . rcParams ['axes.unicode_minus' ]
295
297
else s )
296
298
297
299
def _set_locator (self , locator ):
@@ -515,19 +517,20 @@ def __init__(self, useOffset=None, useMathText=None, useLocale=None):
515
517
# and scientific notation in mathtext
516
518
517
519
if useOffset is None :
518
- useOffset = rcParams ['axes.formatter.useoffset' ]
519
- self ._offset_threshold = rcParams ['axes.formatter.offset_threshold' ]
520
+ useOffset = mpl .rcParams ['axes.formatter.useoffset' ]
521
+ self ._offset_threshold = \
522
+ mpl .rcParams ['axes.formatter.offset_threshold' ]
520
523
self .set_useOffset (useOffset )
521
- self ._usetex = rcParams ['text.usetex' ]
524
+ self ._usetex = mpl . rcParams ['text.usetex' ]
522
525
if useMathText is None :
523
- useMathText = rcParams ['axes.formatter.use_mathtext' ]
526
+ useMathText = mpl . rcParams ['axes.formatter.use_mathtext' ]
524
527
self .set_useMathText (useMathText )
525
528
self .orderOfMagnitude = 0
526
529
self .format = ''
527
530
self ._scientific = True
528
- self ._powerlimits = rcParams ['axes.formatter.limits' ]
531
+ self ._powerlimits = mpl . rcParams ['axes.formatter.limits' ]
529
532
if useLocale is None :
530
- useLocale = rcParams ['axes.formatter.use_locale' ]
533
+ useLocale = mpl . rcParams ['axes.formatter.use_locale' ]
531
534
self ._useLocale = useLocale
532
535
533
536
def get_useOffset (self ):
@@ -548,7 +551,7 @@ def get_useLocale(self):
548
551
549
552
def set_useLocale (self , val ):
550
553
if val is None :
551
- self ._useLocale = rcParams ['axes.formatter.use_locale' ]
554
+ self ._useLocale = mpl . rcParams ['axes.formatter.use_locale' ]
552
555
else :
553
556
self ._useLocale = val
554
557
@@ -559,7 +562,7 @@ def get_useMathText(self):
559
562
560
563
def set_useMathText (self , val ):
561
564
if val is None :
562
- self ._useMathText = rcParams ['axes.formatter.use_mathtext' ]
565
+ self ._useMathText = mpl . rcParams ['axes.formatter.use_mathtext' ]
563
566
else :
564
567
self ._useMathText = val
565
568
@@ -882,7 +885,7 @@ def __init__(self, base=10.0, labelOnlyBase=False,
882
885
self ._base = float (base )
883
886
self .labelOnlyBase = labelOnlyBase
884
887
if minor_thresholds is None :
885
- if rcParams ['_internal.classic_mode' ]:
888
+ if mpl . rcParams ['_internal.classic_mode' ]:
886
889
minor_thresholds = (0 , 0 )
887
890
else :
888
891
minor_thresholds = (1 , 0.4 )
@@ -1075,8 +1078,8 @@ def __call__(self, x, pos=None):
1075
1078
1076
1079
The position *pos* is ignored.
1077
1080
"""
1078
- usetex = rcParams ['text.usetex' ]
1079
- min_exp = rcParams ['axes.formatter.min_exponent' ]
1081
+ usetex = mpl . rcParams ['text.usetex' ]
1082
+ min_exp = mpl . rcParams ['axes.formatter.min_exponent' ]
1080
1083
1081
1084
if x == 0 : # Symlog
1082
1085
return r'$\mathdefault{0}$'
@@ -1400,7 +1403,7 @@ def get_usetex(self):
1400
1403
1401
1404
def set_usetex (self , val ):
1402
1405
if val is None :
1403
- self ._usetex = rcParams ['text.usetex' ]
1406
+ self ._usetex = mpl . rcParams ['text.usetex' ]
1404
1407
else :
1405
1408
self ._usetex = val
1406
1409
@@ -1411,7 +1414,7 @@ def get_useMathText(self):
1411
1414
1412
1415
def set_useMathText (self , val ):
1413
1416
if val is None :
1414
- self ._useMathText = rcParams ['axes.formatter.use_mathtext' ]
1417
+ self ._useMathText = mpl . rcParams ['axes.formatter.use_mathtext' ]
1415
1418
else :
1416
1419
self ._useMathText = val
1417
1420
@@ -1580,7 +1583,7 @@ def symbol(self):
1580
1583
symbol = self ._symbol
1581
1584
if not symbol :
1582
1585
symbol = ''
1583
- elif rcParams ['text.usetex' ] and not self ._is_latex :
1586
+ elif mpl . rcParams ['text.usetex' ] and not self ._is_latex :
1584
1587
# Source: http://www.personal.ceu.hu/tex/specchar.htm
1585
1588
# Backslash must be first for this to work correctly since
1586
1589
# it keeps getting added in
@@ -1876,7 +1879,7 @@ def view_limits(self, vmin, vmax):
1876
1879
vmin -= 1
1877
1880
vmax += 1
1878
1881
1879
- if rcParams ['axes.autolimit_mode' ] == 'round_numbers' :
1882
+ if mpl . rcParams ['axes.autolimit_mode' ] == 'round_numbers' :
1880
1883
exponent , remainder = divmod (
1881
1884
math .log10 (vmax - vmin ), math .log10 (max (self .numticks - 1 , 1 )))
1882
1885
exponent -= (remainder < .5 )
@@ -1919,7 +1922,7 @@ def view_limits(self, dmin, dmax):
1919
1922
Set the view limits to the nearest multiples of base that
1920
1923
contain the data.
1921
1924
"""
1922
- if rcParams ['axes.autolimit_mode' ] == 'round_numbers' :
1925
+ if mpl . rcParams ['axes.autolimit_mode' ] == 'round_numbers' :
1923
1926
vmin = self ._edge .le (dmin ) * self ._edge .step
1924
1927
vmax = self ._edge .ge (dmax ) * self ._edge .step
1925
1928
if vmin == vmax :
@@ -2145,7 +2148,7 @@ def _raw_ticks(self, vmin, vmax):
2145
2148
istep = np .nonzero (steps >= raw_step )[0 ][0 ]
2146
2149
2147
2150
# Classic round_numbers mode may require a larger step.
2148
- if rcParams ['axes.autolimit_mode' ] == 'round_numbers' :
2151
+ if mpl . rcParams ['axes.autolimit_mode' ] == 'round_numbers' :
2149
2152
for istep in range (istep , len (steps )):
2150
2153
step = steps [istep ]
2151
2154
best_vmin = (_vmin // step ) * step
@@ -2205,7 +2208,7 @@ def view_limits(self, dmin, dmax):
2205
2208
dmin , dmax = mtransforms .nonsingular (
2206
2209
dmin , dmax , expander = 1e-12 , tiny = 1e-13 )
2207
2210
2208
- if rcParams ['axes.autolimit_mode' ] == 'round_numbers' :
2211
+ if mpl . rcParams ['axes.autolimit_mode' ] == 'round_numbers' :
2209
2212
return self ._raw_ticks (dmin , dmax )[[0 , - 1 ]]
2210
2213
else :
2211
2214
return dmin , dmax
@@ -2317,7 +2320,7 @@ def __init__(self, base=10.0, subs=(1.0,), numdecs=4, numticks=None):
2317
2320
2318
2321
"""
2319
2322
if numticks is None :
2320
- if rcParams ['_internal.classic_mode' ]:
2323
+ if mpl . rcParams ['_internal.classic_mode' ]:
2321
2324
numticks = 15
2322
2325
else :
2323
2326
numticks = 'auto'
@@ -2420,7 +2423,7 @@ def tick_values(self, vmin, vmax):
2420
2423
2421
2424
# Get decades between major ticks.
2422
2425
stride = (max (math .ceil (numdec / (numticks - 1 )), 1 )
2423
- if rcParams ['_internal.classic_mode' ] else
2426
+ if mpl . rcParams ['_internal.classic_mode' ] else
2424
2427
(numdec + 1 ) // numticks + 1 )
2425
2428
2426
2429
# Does subs include anything other than 1? Essentially a hack to know
@@ -2469,7 +2472,7 @@ def view_limits(self, vmin, vmax):
2469
2472
vmax = math .ceil (math .log (vmax ) / math .log (b ))
2470
2473
vmin = b ** (vmax - self .numdecs )
2471
2474
2472
- if rcParams ['axes.autolimit_mode' ] == 'round_numbers' :
2475
+ if mpl . rcParams ['axes.autolimit_mode' ] == 'round_numbers' :
2473
2476
vmin = _decade_less_equal (vmin , self ._base )
2474
2477
vmax = _decade_greater_equal (vmax , self ._base )
2475
2478
@@ -2627,7 +2630,7 @@ def view_limits(self, vmin, vmax):
2627
2630
if vmax < vmin :
2628
2631
vmin , vmax = vmax , vmin
2629
2632
2630
- if rcParams ['axes.autolimit_mode' ] == 'round_numbers' :
2633
+ if mpl . rcParams ['axes.autolimit_mode' ] == 'round_numbers' :
2631
2634
vmin = _decade_less_equal (vmin , b )
2632
2635
vmax = _decade_greater_equal (vmax , b )
2633
2636
if vmin == vmax :
@@ -2797,7 +2800,7 @@ def __init__(self):
2797
2800
To know the values of the non-public parameters, please have a
2798
2801
look to the defaults of `~matplotlib.ticker.MaxNLocator`.
2799
2802
"""
2800
- if rcParams ['_internal.classic_mode' ]:
2803
+ if mpl . rcParams ['_internal.classic_mode' ]:
2801
2804
nbins = 9
2802
2805
steps = [1 , 2 , 5 , 10 ]
2803
2806
else :
0 commit comments