67
67
MaxNLocator
68
68
from matplotlib .backends import pylab_setup
69
69
70
- ## Backend detection ##
70
+
71
+ # # Backend detection ##
71
72
def _backend_selection ():
72
73
""" If rcParams['backend_fallback'] is true, check to see if the
73
74
current backend is compatible with the current running event
74
75
loop, and if not switches to a compatible one.
75
76
"""
76
77
backend = rcParams ['backend' ]
77
- if not rcParams ['backend_fallback' ] or \
78
- backend not in _interactive_bk :
78
+ if not ( rcParams ['backend_fallback' ] or
79
+ backend not in _interactive_bk ) :
79
80
return
80
81
is_agg_backend = rcParams ['backend' ].endswith ('Agg' )
81
- if 'wx' in sys .modules and not backend in ('WX' , 'WXAgg' ):
82
+ if 'wx' in sys .modules and backend not in ('WX' , 'WXAgg' ):
82
83
import wx
83
84
if wx .App .IsMainLoopRunning ():
84
85
rcParams ['backend' ] = 'wx' + 'Agg' * is_agg_backend
@@ -676,7 +677,8 @@ def close(*args):
676
677
elif isinstance (arg , Figure ):
677
678
_pylab_helpers .Gcf .destroy_fig (arg )
678
679
else :
679
- raise TypeError ('Unrecognized argument type %s to close' % type (arg ))
680
+ raise TypeError (
681
+ 'Unrecognized argument type %s to close' % type (arg ))
680
682
else :
681
683
raise TypeError ('close takes 0 or 1 arguments' )
682
684
@@ -806,13 +808,14 @@ def figlegend(*args, **kwargs):
806
808
return fig .legend (* args , ** kwargs )
807
809
808
810
809
- ## Figure and Axes hybrid ##
811
+ # # Figure and Axes hybrid ##
810
812
811
813
_hold_msg = """pyplot.hold is deprecated.
812
814
Future behavior will be consistent with the long-time default:
813
815
plot commands add elements without first clearing the
814
816
Axes and/or Figure."""
815
817
818
+
816
819
@deprecated ("2.0" , message = _hold_msg )
817
820
def hold (b = None ):
818
821
"""
@@ -847,6 +850,7 @@ def hold(b=None):
847
850
# a second warning, but "Oh, well...".
848
851
rc ('axes' , hold = b )
849
852
853
+
850
854
@deprecated ("2.0" , message = _hold_msg )
851
855
def ishold ():
852
856
"""
@@ -874,6 +878,7 @@ def over(func, *args, **kwargs):
874
878
func (* args , ** kwargs )
875
879
ax ._hold = h
876
880
881
+
877
882
## Axes ##
878
883
879
884
@@ -1025,7 +1030,8 @@ def subplot(*args, **kwargs):
1025
1030
# first, the plot (and its axes) previously created, will be removed
1026
1031
plt.subplot(211)
1027
1032
plt.plot(range(12))
1028
- plt.subplot(212, facecolor='y') # creates 2nd subplot with yellow background
1033
+ # creates 2nd subplot with yellow background
1034
+ plt.subplot(212, facecolor='y')
1029
1035
1030
1036
If you do not want this behavior, use the
1031
1037
:meth:`~matplotlib.figure.Figure.add_subplot` method or the
@@ -1062,16 +1068,16 @@ def subplot(*args, **kwargs):
1062
1068
1063
1069
"""
1064
1070
# if subplot called without arguments, create subplot(1,1,1)
1065
- if len (args )== 0 :
1066
- args = (1 ,1 , 1 )
1071
+ if len (args ) == 0 :
1072
+ args = (1 , 1 , 1 )
1067
1073
1068
1074
# This check was added because it is very easy to type
1069
1075
# subplot(1, 2, False) when subplots(1, 2, False) was intended
1070
1076
# (sharex=False, that is). In most cases, no error will
1071
1077
# ever occur, but mysterious behavior can result because what was
1072
1078
# intended to be the sharex argument is instead treated as a
1073
1079
# subplot index for subplot()
1074
- if len (args ) >= 3 and isinstance (args [2 ], bool ) :
1080
+ if len (args ) >= 3 and isinstance (args [2 ], bool ):
1075
1081
warnings .warn ("The subplot index argument to subplot() appears"
1076
1082
" to be a boolean. Did you intend to use subplots()?" )
1077
1083
@@ -1080,10 +1086,12 @@ def subplot(*args, **kwargs):
1080
1086
bbox = a .bbox
1081
1087
byebye = []
1082
1088
for other in fig .axes :
1083
- if other == a : continue
1089
+ if other == a :
1090
+ continue
1084
1091
if bbox .fully_overlaps (other .bbox ):
1085
1092
byebye .append (other )
1086
- for ax in byebye : delaxes (ax )
1093
+ for ax in byebye :
1094
+ delaxes (ax )
1087
1095
1088
1096
return a
1089
1097
@@ -1259,7 +1267,7 @@ def twinx(ax=None):
1259
1267
For an example
1260
1268
"""
1261
1269
if ax is None :
1262
- ax = gca ()
1270
+ ax = gca ()
1263
1271
ax1 = ax .twinx ()
1264
1272
return ax1
1265
1273
@@ -1272,7 +1280,7 @@ def twiny(ax=None):
1272
1280
returned.
1273
1281
"""
1274
1282
if ax is None :
1275
- ax = gca ()
1283
+ ax = gca ()
1276
1284
ax1 = ax .twiny ()
1277
1285
return ax1
1278
1286
@@ -1678,24 +1686,23 @@ def yticks(*args, **kwargs):
1678
1686
"""
1679
1687
ax = kwargs .pop ('ax' , gca ())
1680
1688
1681
- if len (args )== 0 :
1689
+ if len (args ) == 0 :
1682
1690
locs = ax .get_yticks ()
1683
1691
labels = ax .get_yticklabels ()
1684
- elif len (args )== 1 :
1692
+ elif len (args ) == 1 :
1685
1693
locs = ax .set_yticks (args [0 ])
1686
1694
labels = ax .get_yticklabels ()
1687
- elif len (args )== 2 :
1695
+ elif len (args ) == 2 :
1688
1696
locs = ax .set_yticks (args [0 ])
1689
1697
labels = ax .set_yticklabels (args [1 ], ** kwargs )
1690
- else : raise TypeError ('Illegal number of arguments to yticks' )
1698
+ else :
1699
+ raise TypeError ('Illegal number of arguments to yticks' )
1691
1700
if len (kwargs ):
1692
1701
for l in labels :
1693
1702
l .update (kwargs )
1694
1703
1695
-
1696
- return ( locs ,
1697
- silent_list ('Text yticklabel' , labels )
1698
- )
1704
+ return (locs ,
1705
+ silent_list ('Text yticklabel' , labels ))
1699
1706
1700
1707
1701
1708
def minorticks_on (ax = None ):
0 commit comments