17
17
18
18
import warnings
19
19
20
+ import numpy as np
20
21
import matplotlib .axes as maxes
21
22
from matplotlib .axes import Axes , rcParams
22
23
from matplotlib import cbook
26
27
from matplotlib import docstring
27
28
import matplotlib .scale as mscale
28
29
from matplotlib .tri .triangulation import Triangulation
29
- import numpy as np
30
30
from matplotlib import colors as mcolors
31
31
from matplotlib .colors import Normalize , LightSource
32
32
33
33
from . import art3d
34
34
from . import proj3d
35
35
from . import axis3d
36
36
37
+
37
38
def unit_bbox ():
38
39
box = Bbox (np .array ([[0 , 0 ], [1 , 1 ]]))
39
40
return box
40
41
42
+
41
43
class Axes3D (Axes ):
42
44
"""
43
45
3D axes object.
@@ -302,7 +304,7 @@ def get_axis_position(self):
302
304
def update_datalim (self , xys , ** kwargs ):
303
305
pass
304
306
305
- def get_autoscale_on (self ) :
307
+ def get_autoscale_on (self ):
306
308
"""
307
309
Get whether autoscaling is applied for all axes on plot commands
308
310
@@ -311,7 +313,7 @@ def get_autoscale_on(self) :
311
313
"""
312
314
return Axes .get_autoscale_on (self ) and self .get_autoscalez_on ()
313
315
314
- def get_autoscalez_on (self ) :
316
+ def get_autoscalez_on (self ):
315
317
"""
316
318
Get whether autoscaling for the z-axis is applied on plot commands
317
319
@@ -320,7 +322,7 @@ def get_autoscalez_on(self) :
320
322
"""
321
323
return self ._autoscaleZon
322
324
323
- def set_autoscale_on (self , b ) :
325
+ def set_autoscale_on (self , b ):
324
326
"""
325
327
Set whether autoscaling is applied on plot commands
326
328
@@ -332,7 +334,7 @@ def set_autoscale_on(self, b) :
332
334
Axes .set_autoscale_on (self , b )
333
335
self .set_autoscalez_on (b )
334
336
335
- def set_autoscalez_on (self , b ) :
337
+ def set_autoscalez_on (self , b ):
336
338
"""
337
339
Set whether autoscaling for the z-axis is applied on plot commands
338
340
@@ -343,7 +345,7 @@ def set_autoscalez_on(self, b) :
343
345
"""
344
346
self ._autoscaleZon = b
345
347
346
- def set_zmargin (self , m ) :
348
+ def set_zmargin (self , m ):
347
349
"""
348
350
Set padding of Z data limits prior to autoscaling.
349
351
@@ -360,7 +362,7 @@ def set_zmargin(self, m) :
360
362
self ._zmargin = m
361
363
self .stale = True
362
364
363
- def margins (self , * args , ** kw ) :
365
+ def margins (self , * args , ** kw ):
364
366
"""
365
367
Convenience method to set or retrieve autoscaling margins.
366
368
@@ -419,14 +421,14 @@ def margins(self, *args, **kw) :
419
421
if mz is not None :
420
422
self .set_zmargin (mz )
421
423
422
- scalex = ( mx is not None )
423
- scaley = ( my is not None )
424
- scalez = ( mz is not None )
424
+ scalex = mx is not None
425
+ scaley = my is not None
426
+ scalez = mz is not None
425
427
426
428
self .autoscale_view (tight = tight , scalex = scalex , scaley = scaley ,
427
429
scalez = scalez )
428
430
429
- def autoscale (self , enable = True , axis = 'both' , tight = None ) :
431
+ def autoscale (self , enable = True , axis = 'both' , tight = None ):
430
432
"""
431
433
Convenience method for simple axis view autoscaling.
432
434
See :meth:`matplotlib.axes.Axes.autoscale` for full explanation.
@@ -477,7 +479,7 @@ def auto_scale_xyz(self, X, Y, Z=None, had_data=None):
477
479
self .autoscale_view ()
478
480
479
481
def autoscale_view (self , tight = None , scalex = True , scaley = True ,
480
- scalez = True ) :
482
+ scalez = True ):
481
483
"""
482
484
Autoscale the view limits using the data limits.
483
485
See :meth:`matplotlib.axes.Axes.autoscale_view` for documentation.
@@ -764,7 +766,7 @@ def get_zlim3d(self):
764
766
return self .zz_viewLim .intervalx
765
767
get_zlim = get_zlim3d
766
768
767
- def get_zscale (self ) :
769
+ def get_zscale (self ):
768
770
"""
769
771
Return the zaxis scale string %s
770
772
@@ -775,7 +777,7 @@ def get_zscale(self) :
775
777
776
778
# We need to slightly redefine these to pass scalez=False
777
779
# to their calls of autoscale_view.
778
- def set_xscale (self , value , ** kwargs ) :
780
+ def set_xscale (self , value , ** kwargs ):
779
781
self .xaxis ._set_scale (value , ** kwargs )
780
782
self .autoscale_view (scaley = False , scalez = False )
781
783
self ._update_transScale ()
@@ -786,7 +788,7 @@ def set_xscale(self, value, **kwargs) :
786
788
This function was added, but not tested. Please report any bugs.
787
789
"""
788
790
789
- def set_yscale (self , value , ** kwargs ) :
791
+ def set_yscale (self , value , ** kwargs ):
790
792
self .yaxis ._set_scale (value , ** kwargs )
791
793
self .autoscale_view (scalex = False , scalez = False )
792
794
self ._update_transScale ()
@@ -799,7 +801,7 @@ def set_yscale(self, value, **kwargs) :
799
801
"""
800
802
801
803
@docstring .dedent_interpd
802
- def set_zscale (self , value , ** kwargs ) :
804
+ def set_zscale (self , value , ** kwargs ):
803
805
"""
804
806
Set the scaling of the z-axis: %(scale)s
805
807
@@ -845,7 +847,7 @@ def get_zticks(self, minor=False):
845
847
"""
846
848
return self .zaxis .get_ticklocs (minor = minor )
847
849
848
- def get_zmajorticklabels (self ) :
850
+ def get_zmajorticklabels (self ):
849
851
"""
850
852
Get the ztick labels as a list of Text instances
851
853
@@ -854,7 +856,7 @@ def get_zmajorticklabels(self) :
854
856
return cbook .silent_list ('Text zticklabel' ,
855
857
self .zaxis .get_majorticklabels ())
856
858
857
- def get_zminorticklabels (self ) :
859
+ def get_zminorticklabels (self ):
858
860
"""
859
861
Get the ztick labels as a list of Text instances
860
862
@@ -867,7 +869,7 @@ def get_zminorticklabels(self) :
867
869
return cbook .silent_list ('Text zticklabel' ,
868
870
self .zaxis .get_minorticklabels ())
869
871
870
- def set_zticklabels (self , * args , ** kwargs ) :
872
+ def set_zticklabels (self , * args , ** kwargs ):
871
873
"""
872
874
Set z-axis tick labels.
873
875
See :meth:`matplotlib.axes.Axes.set_yticklabels` for more details.
@@ -879,7 +881,7 @@ def set_zticklabels(self, *args, **kwargs) :
879
881
"""
880
882
return self .zaxis .set_ticklabels (* args , ** kwargs )
881
883
882
- def get_zticklabels (self , minor = False ) :
884
+ def get_zticklabels (self , minor = False ):
883
885
"""
884
886
Get ztick labels as a list of Text instances.
885
887
See :meth:`matplotlib.axes.Axes.get_yticklabels` for more details.
@@ -892,7 +894,7 @@ def get_zticklabels(self, minor=False) :
892
894
return cbook .silent_list ('Text zticklabel' ,
893
895
self .zaxis .get_ticklabels (minor = minor ))
894
896
895
- def zaxis_date (self , tz = None ) :
897
+ def zaxis_date (self , tz = None ):
896
898
"""
897
899
Sets up z-axis ticks and labels that treat the z data as dates.
898
900
@@ -909,7 +911,7 @@ def zaxis_date(self, tz=None) :
909
911
"""
910
912
self .zaxis .axis_date (tz )
911
913
912
- def get_zticklines (self ) :
914
+ def get_zticklines (self ):
913
915
"""
914
916
Get ztick lines as a list of Line2D instances.
915
917
Note that this function is provided merely for completeness.
@@ -1032,15 +1034,15 @@ def mouse_init(self, rotate_btn=1, zoom_btn=3):
1032
1034
self ._rotate_btn = np .atleast_1d (rotate_btn ).tolist ()
1033
1035
self ._zoom_btn = np .atleast_1d (zoom_btn ).tolist ()
1034
1036
1035
- def can_zoom (self ) :
1037
+ def can_zoom (self ):
1036
1038
"""
1037
1039
Return *True* if this axes supports the zoom box button functionality.
1038
1040
1039
1041
3D axes objects do not use the zoom box button.
1040
1042
"""
1041
1043
return False
1042
1044
1043
- def can_pan (self ) :
1045
+ def can_pan (self ):
1044
1046
"""
1045
1047
Return *True* if this axes supports the pan/zoom button functionality.
1046
1048
@@ -1199,7 +1201,7 @@ def set_zlabel(self, zlabel, fontdict=None, labelpad=None, **kwargs):
1199
1201
if labelpad is not None : self .zaxis .labelpad = labelpad
1200
1202
return self .zaxis .set_label_text (zlabel , fontdict , ** kwargs )
1201
1203
1202
- def get_zlabel (self ) :
1204
+ def get_zlabel (self ):
1203
1205
"""
1204
1206
Get the z-label text string.
1205
1207
@@ -1270,12 +1272,12 @@ def grid(self, b=True, **kwargs):
1270
1272
This function was changed, but not tested. Please report any bugs.
1271
1273
'''
1272
1274
# TODO: Operate on each axes separately
1273
- if len (kwargs ) :
1275
+ if len (kwargs ):
1274
1276
b = True
1275
1277
self ._draw_grid = cbook ._string_to_bool (b )
1276
1278
self .stale = True
1277
1279
1278
- def ticklabel_format (self , ** kwargs ) :
1280
+ def ticklabel_format (self , ** kwargs ):
1279
1281
"""
1280
1282
Convenience method for manipulating the ScalarFormatter
1281
1283
used by default for linear axes in Axed3D objects.
@@ -1338,7 +1340,7 @@ def ticklabel_format(self, **kwargs) :
1338
1340
raise AttributeError (
1339
1341
"This method only works with the ScalarFormatter." )
1340
1342
1341
- def locator_params (self , axis = 'both' , tight = None , ** kwargs ) :
1343
+ def locator_params (self , axis = 'both' , tight = None , ** kwargs ):
1342
1344
"""
1343
1345
Convenience method for controlling tick locators.
1344
1346
@@ -1363,7 +1365,7 @@ def locator_params(self, axis='both', tight=None, **kwargs) :
1363
1365
self .zaxis .get_major_locator ().set_params (** kwargs )
1364
1366
self .autoscale_view (tight = tight , scalex = _x , scaley = _y , scalez = _z )
1365
1367
1366
- def tick_params (self , axis = 'both' , ** kwargs ) :
1368
+ def tick_params (self , axis = 'both' , ** kwargs ):
1367
1369
"""
1368
1370
Convenience method for changing the appearance of ticks and
1369
1371
tick labels.
@@ -1464,8 +1466,6 @@ def set_zbound(self, lower=None, upper=None):
1464
1466
else :
1465
1467
self .set_zlim (upper , lower , auto = None )
1466
1468
1467
-
1468
-
1469
1469
def text (self , x , y , z , s , zdir = None , ** kwargs ):
1470
1470
'''
1471
1471
Add text to the plot. kwargs will be passed on to Axes.text,
@@ -1653,7 +1653,7 @@ def plot_surface(self, X, Y, Z, *args, **kwargs):
1653
1653
for rs in xrange (0 , rows - 1 , rstride ):
1654
1654
for cs in xrange (0 , cols - 1 , cstride ):
1655
1655
ps = []
1656
- for a in (X , Y , Z ) :
1656
+ for a in (X , Y , Z ):
1657
1657
ztop = a [rs ,cs :min (cols , cs + cstride + 1 )]
1658
1658
zleft = a [rs + 1 :min (rows , rs + rstride + 1 ),
1659
1659
min (cols - 1 , cs + cstride )]
@@ -1837,14 +1837,14 @@ def plot_wireframe(self, X, Y, Z, *args, **kwargs):
1837
1837
if rstride :
1838
1838
rii = list (xrange (0 , rows , rstride ))
1839
1839
# Add the last index only if needed
1840
- if rows > 0 and rii [- 1 ] != (rows - 1 ) :
1840
+ if rows > 0 and rii [- 1 ] != (rows - 1 ):
1841
1841
rii += [rows - 1 ]
1842
1842
else :
1843
1843
rii = []
1844
1844
if cstride :
1845
1845
cii = list (xrange (0 , cols , cstride ))
1846
1846
# Add the last index only if needed
1847
- if cols > 0 and cii [- 1 ] != (cols - 1 ) :
1847
+ if cols > 0 and cii [- 1 ] != (cols - 1 ):
1848
1848
cii += [cols - 1 ]
1849
1849
else :
1850
1850
cii = []
@@ -2060,9 +2060,9 @@ def add_contour_set(self, cset, extend3d=False, stride=5, zdir='z', offset=None)
2060
2060
z = offset
2061
2061
art3d .line_collection_2d_to_3d (linec , z , zdir = zdir )
2062
2062
2063
- def add_contourf_set (self , cset , zdir = 'z' , offset = None ) :
2063
+ def add_contourf_set (self , cset , zdir = 'z' , offset = None ):
2064
2064
zdir = '-' + zdir
2065
- for z , linec in zip (cset .levels , cset .collections ) :
2065
+ for z , linec in zip (cset .levels , cset .collections ):
2066
2066
if offset is not None :
2067
2067
z = offset
2068
2068
art3d .poly_collection_2d_to_3d (linec , z , zdir = zdir )
0 commit comments