9
9
import numpy as np
10
10
11
11
import matplotlib
12
- rcParams = matplotlib .rcParams
13
12
from matplotlib .axes import Axes
14
13
import matplotlib .axis as maxis
15
14
from matplotlib import cbook
21
20
import matplotlib .spines as mspines
22
21
23
22
23
+ rcParams = matplotlib .rcParams
24
+
25
+
24
26
class PolarTransform (mtransforms .Transform ):
25
27
"""
26
28
The base polar transform. This handles projection *theta* and
@@ -526,8 +528,8 @@ def _set_lim_and_transforms(self):
526
528
self ._yaxis_text_transform = mtransforms .TransformWrapper (
527
529
self ._r_label_position + self .transData )
528
530
529
- def get_xaxis_transform (self ,which = 'grid' ):
530
- if which not in ['tick1' ,'tick2' ,'grid' ]:
531
+ def get_xaxis_transform (self ,which = 'grid' ):
532
+ if which not in ['tick1' ,'tick2' ,'grid' ]:
531
533
msg = "'which' must be one of [ 'tick1' | 'tick2' | 'grid' ]"
532
534
raise ValueError (msg )
533
535
return self ._xaxis_transform
@@ -538,8 +540,8 @@ def get_xaxis_text1_transform(self, pad):
538
540
def get_xaxis_text2_transform (self ,pad ):
539
541
return self ._xaxis_text2_transform ,'center' ,'center'
540
542
541
- def get_yaxis_transform (self ,which = 'grid' ):
542
- if which not in ['tick1' ,'tick2' ,'grid' ]:
543
+ def get_yaxis_transform (self ,which = 'grid' ):
544
+ if which not in ['tick1' ,'tick2' ,'grid' ]:
543
545
msg = "'which' must be on of [ 'tick1' | 'tick2' | 'grid' ]"
544
546
raise ValueError (msg )
545
547
return self ._yaxis_transform
@@ -686,7 +688,7 @@ def set_theta_zero_location(self, loc, offset=0.0):
686
688
'S' :np .pi * 1.5 ,
687
689
'SE' :np .pi * 1.75 ,
688
690
'E' :0 ,
689
- 'NE' :np .pi * 0.25 }
691
+ 'NE' :np .pi * 0.25 }
690
692
return self .set_theta_offset (mapping [loc ]+ np .deg2rad (offset ))
691
693
692
694
def set_theta_direction (self ,direction ):
@@ -707,7 +709,8 @@ def set_theta_direction(self, direction):
707
709
elif direction in (1 ,- 1 ):
708
710
mtx [0 ,0 ]= direction
709
711
else :
710
- raise ValueError ("direction must be 1, -1, clockwise or counterclockwise" )
712
+ raise ValueError (
713
+ "direction must be 1, -1, clockwise or counterclockwise" )
711
714
self ._direction .invalidate ()
712
715
713
716
def get_theta_direction (self ):
@@ -773,6 +776,7 @@ def set_yscale(self, *args, **kwargs):
773
776
774
777
def set_rscale (self ,* args ,** kwargs ):
775
778
return Axes .set_yscale (self ,* args ,** kwargs )
779
+
776
780
def set_rticks (self ,* args ,** kwargs ):
777
781
return Axes .set_yticks (self ,* args ,** kwargs )
778
782
@@ -857,7 +861,8 @@ def set_rgrids(self, radii, labels=None, angle=None, fmt=None,
857
861
858
862
def set_xscale (self ,scale ,* args ,** kwargs ):
859
863
if scale != 'linear' :
860
- raise NotImplementedError ("You can not set the xscale on a polar plot." )
864
+ raise NotImplementedError (
865
+ "You can not set the xscale on a polar plot." )
861
866
862
867
def format_coord (self ,theta ,r ):
863
868
"""
@@ -868,7 +873,9 @@ def format_coord(self, theta, r):
868
873
# \u03b8: lower-case theta
869
874
# \u03c0: lower-case pi
870
875
# \u00b0: degree symbol
871
- return '\u03b8 =%0.3f\u03c0 (%0.3f\u00b0 ), r=%0.3f' % (theta ,theta * 180.0 ,r )
876
+ return '\u03b8 =%0.3f\u03c0 (%0.3f\u00b0 ), r=%0.3f' % (theta ,
877
+ theta * 180.0 ,
878
+ r )
872
879
873
880
def get_data_ratio (self ):
874
881
'''
@@ -877,7 +884,7 @@ def get_data_ratio(self):
877
884
'''
878
885
return 1.0
879
886
880
- ## # Interactive panning
887
+ # # # Interactive panning
881
888
882
889
def can_zoom (self ):
883
890
"""
@@ -887,7 +894,7 @@ def can_zoom(self):
887
894
"""
888
895
return False
889
896
890
- def can_pan (self ) :
897
+ def can_pan (self ):
891
898
"""
892
899
Return *True* if this axes supports the pan/zoom button functionality.
893
900
@@ -909,14 +916,13 @@ def start_pan(self, x, y, button):
909
916
mode = 'zoom'
910
917
911
918
self ._pan_start = cbook .Bunch (
912
- rmax = self .get_rmax (),
913
- trans = self .transData .frozen (),
914
- trans_inverse = self .transData .inverted ().frozen (),
915
- r_label_angle = self .get_rlabel_position (),
916
- x = x ,
917
- y = y ,
918
- mode = mode
919
- )
919
+ rmax = self .get_rmax (),
920
+ trans = self .transData .frozen (),
921
+ trans_inverse = self .transData .inverted ().frozen (),
922
+ r_label_angle = self .get_rlabel_position (),
923
+ x = x ,
924
+ y = y ,
925
+ mode = mode )
920
926
921
927
def end_pan (self ):
922
928
del self ._pan_start
@@ -950,8 +956,6 @@ def drag_pan(self, button, key, x, y):
950
956
startt ,startr = p .trans_inverse .transform_point ((p .x ,p .y ))
951
957
t ,r = p .trans_inverse .transform_point ((x ,y ))
952
958
953
- dr = r - startr
954
-
955
959
# Deal with r
956
960
scale = r / startr
957
961
self .set_rmax (p .rmax / scale )
@@ -987,7 +991,8 @@ def drag_pan(self, button, key, x, y):
987
991
# vertices = self.transform(vertices)
988
992
989
993
# result = np.zeros((len(vertices) * 3 - 2, 2), np.float_)
990
- # codes = mpath.Path.CURVE4 * np.ones((len(vertices) * 3 - 2, ), mpath.Path.code_type)
994
+ # codes = mpath.Path.CURVE4 * np.ones((len(vertices) * 3 - 2, ),
995
+ # mpath.Path.code_type)
991
996
# result[0] = vertices[0]
992
997
# codes[0] = mpath.Path.MOVETO
993
998
@@ -1024,8 +1029,8 @@ def drag_pan(self, button, key, x, y):
1024
1029
1025
1030
# result[3::3] = p1
1026
1031
1027
- # print vertices[-2:]
1028
- # print result[-2:]
1032
+ # print( vertices[-2:])
1033
+ # print( result[-2:])
1029
1034
1030
1035
# return mpath.Path(result, codes)
1031
1036
@@ -1039,12 +1044,13 @@ def drag_pan(self, button, key, x, y):
1039
1044
# maxtd = td.max()
1040
1045
# interpolate = np.ceil(maxtd / halfpi)
1041
1046
1042
- # print "interpolate", interpolate
1047
+ # print( "interpolate", interpolate)
1043
1048
# if interpolate > 1.0:
1044
1049
# vertices = self.interpolate(vertices, interpolate)
1045
1050
1046
1051
# result = np.zeros((len(vertices) * 3 - 2, 2), np.float_)
1047
- # codes = mpath.Path.CURVE4 * np.ones((len(vertices) * 3 - 2, ), mpath.Path.code_type)
1052
+ # codes = mpath.Path.CURVE4 * np.ones((len(vertices) * 3 - 2, ),
1053
+ # mpath.Path.code_type)
1048
1054
# result[0] = vertices[0]
1049
1055
# codes[0] = mpath.Path.MOVETO
1050
1056
@@ -1066,16 +1072,19 @@ def drag_pan(self, button, key, x, y):
1066
1072
1067
1073
# result[1::3, 0] = t0 + (tkappa * td_scaled)
1068
1074
# result[1::3, 1] = r0*hyp_kappa
1069
- # # result[1::3, 1] = r0 / np.cos(tkappa * td_scaled) # np.sqrt(r0*r0 + ravg_kappa*ravg_kappa)
1075
+ # # result[1::3, 1] = r0 / np.cos(tkappa * td_scaled)
1076
+ # # np.sqrt(r0*r0 + ravg_kappa*ravg_kappa)
1070
1077
1071
1078
# result[2::3, 0] = t1 - (tkappa * td_scaled)
1072
1079
# result[2::3, 1] = r1*hyp_kappa
1073
- # # result[2::3, 1] = r1 / np.cos(tkappa * td_scaled) # np.sqrt(r1*r1 + ravg_kappa*ravg_kappa)
1080
+ # # result[2::3, 1] = r1 / np.cos(tkappa * td_scaled)
1081
+ # # np.sqrt(r1*r1 + ravg_kappa*ravg_kappa)
1074
1082
1075
1083
# result[3::3, 0] = t1
1076
1084
# result[3::3, 1] = r1
1077
1085
1078
- # print vertices[:6], result[:6], t0[:6], t1[:6], td[:6], td_scaled[:6], tkappa
1086
+ # print(vertices[:6], result[:6], t0[:6], t1[:6], td[:6],
1087
+ # td_scaled[:6], tkappa)
1079
1088
# result = self.transform(result)
1080
1089
# return mpath.Path(result, codes)
1081
1090
# transform_path_non_affine = transform_path