1
1
from __future__ import (absolute_import , division , print_function ,
2
2
unicode_literals )
3
3
4
- import six
5
-
6
- import math
7
- import warnings
8
-
9
4
import numpy as np
10
5
11
- import matplotlib
12
- rcParams = matplotlib .rcParams
13
6
from matplotlib .axes import Axes
14
7
import matplotlib .axis as maxis
15
8
from matplotlib import cbook
16
9
from matplotlib import docstring
17
10
import matplotlib .patches as mpatches
18
11
import matplotlib .path as mpath
12
+ from matplotlib import rcParams
19
13
import matplotlib .ticker as mticker
20
14
import matplotlib .transforms as mtransforms
21
15
import matplotlib .spines as mspines
@@ -530,8 +524,8 @@ def _set_lim_and_transforms(self):
530
524
self ._yaxis_text_transform = mtransforms .TransformWrapper (
531
525
self ._r_label_position + self .transData )
532
526
533
- def get_xaxis_transform (self ,which = 'grid' ):
534
- if which not in ['tick1' ,'tick2' ,'grid' ]:
527
+ def get_xaxis_transform (self , which = 'grid' ):
528
+ if which not in ['tick1' , 'tick2' , 'grid' ]:
535
529
msg = "'which' must be one of [ 'tick1' | 'tick2' | 'grid' ]"
536
530
raise ValueError (msg )
537
531
return self ._xaxis_transform
@@ -542,8 +536,8 @@ def get_xaxis_text1_transform(self, pad):
542
536
def get_xaxis_text2_transform (self , pad ):
543
537
return self ._xaxis_text2_transform , 'center' , 'center'
544
538
545
- def get_yaxis_transform (self ,which = 'grid' ):
546
- if which not in ['tick1' ,'tick2' ,'grid' ]:
539
+ def get_yaxis_transform (self , which = 'grid' ):
540
+ if which not in ['tick1' , 'tick2' , 'grid' ]:
547
541
msg = "'which' must be on of [ 'tick1' | 'tick2' | 'grid' ]"
548
542
raise ValueError (msg )
549
543
return self ._yaxis_transform
@@ -715,7 +709,7 @@ def set_theta_zero_location(self, loc, offset=0.0):
715
709
'S' : np .pi * 1.5 ,
716
710
'SE' : np .pi * 1.75 ,
717
711
'E' : 0 ,
718
- 'NE' : np .pi * 0.25 }
712
+ 'NE' : np .pi * 0.25 }
719
713
return self .set_theta_offset (mapping [loc ] + np .deg2rad (offset ))
720
714
721
715
def set_theta_direction (self , direction ):
@@ -736,7 +730,8 @@ def set_theta_direction(self, direction):
736
730
elif direction in (1 , - 1 ):
737
731
mtx [0 , 0 ] = direction
738
732
else :
739
- raise ValueError ("direction must be 1, -1, clockwise or counterclockwise" )
733
+ raise ValueError (
734
+ "direction must be 1, -1, clockwise or counterclockwise" )
740
735
self ._direction .invalidate ()
741
736
742
737
def get_theta_direction (self ):
@@ -802,6 +797,7 @@ def set_yscale(self, *args, **kwargs):
802
797
803
798
def set_rscale (self , * args , ** kwargs ):
804
799
return Axes .set_yscale (self , * args , ** kwargs )
800
+
805
801
def set_rticks (self , * args , ** kwargs ):
806
802
return Axes .set_yticks (self , * args , ** kwargs )
807
803
@@ -886,16 +882,17 @@ def set_rgrids(self, radii, labels=None, angle=None, fmt=None,
886
882
887
883
def set_xscale (self , scale , * args , ** kwargs ):
888
884
if scale != 'linear' :
889
- raise NotImplementedError ("You can not set the xscale on a polar plot." )
885
+ raise NotImplementedError (
886
+ "You can not set the xscale on a polar plot." )
890
887
891
888
def format_coord (self , theta , r ):
892
889
"""
893
890
Return a format string formatting the coordinate using Unicode
894
891
characters.
895
892
"""
896
893
if theta < 0 :
897
- theta += 2 * math .pi
898
- theta /= math .pi
894
+ theta += 2 * np .pi
895
+ theta /= np .pi
899
896
return ('\N{GREEK SMALL LETTER THETA} =%0.3f\N{GREEK SMALL LETTER PI} '
900
897
'(%0.3f\N{DEGREE SIGN} ), r=%0.3f' ) % (theta , theta * 180.0 , r )
901
898
@@ -906,7 +903,7 @@ def get_data_ratio(self):
906
903
'''
907
904
return 1.0
908
905
909
- ## # Interactive panning
906
+ # # # Interactive panning
910
907
911
908
def can_zoom (self ):
912
909
"""
@@ -916,7 +913,7 @@ def can_zoom(self):
916
913
"""
917
914
return False
918
915
919
- def can_pan (self ) :
916
+ def can_pan (self ):
920
917
"""
921
918
Return *True* if this axes supports the pan/zoom button functionality.
922
919
@@ -938,14 +935,13 @@ def start_pan(self, x, y, button):
938
935
mode = 'zoom'
939
936
940
937
self ._pan_start = cbook .Bunch (
941
- rmax = self .get_rmax (),
942
- trans = self .transData .frozen (),
943
- trans_inverse = self .transData .inverted ().frozen (),
944
- r_label_angle = self .get_rlabel_position (),
945
- x = x ,
946
- y = y ,
947
- mode = mode
948
- )
938
+ rmax = self .get_rmax (),
939
+ trans = self .transData .frozen (),
940
+ trans_inverse = self .transData .inverted ().frozen (),
941
+ r_label_angle = self .get_rlabel_position (),
942
+ x = x ,
943
+ y = y ,
944
+ mode = mode )
949
945
950
946
def end_pan (self ):
951
947
del self ._pan_start
@@ -979,8 +975,6 @@ def drag_pan(self, button, key, x, y):
979
975
startt , startr = p .trans_inverse .transform_point ((p .x , p .y ))
980
976
t , r = p .trans_inverse .transform_point ((x , y ))
981
977
982
- dr = r - startr
983
-
984
978
# Deal with r
985
979
scale = r / startr
986
980
self .set_rmax (p .rmax / scale )
@@ -1016,7 +1010,8 @@ def drag_pan(self, button, key, x, y):
1016
1010
# vertices = self.transform(vertices)
1017
1011
1018
1012
# result = np.zeros((len(vertices) * 3 - 2, 2), float)
1019
- # codes = mpath.Path.CURVE4 * np.ones((len(vertices) * 3 - 2, ), mpath.Path.code_type)
1013
+ # codes = mpath.Path.CURVE4 * np.ones((len(vertices) * 3 - 2, ),
1014
+ # mpath.Path.code_type)
1020
1015
# result[0] = vertices[0]
1021
1016
# codes[0] = mpath.Path.MOVETO
1022
1017
@@ -1053,8 +1048,8 @@ def drag_pan(self, button, key, x, y):
1053
1048
1054
1049
# result[3::3] = p1
1055
1050
1056
- # print vertices[-2:]
1057
- # print result[-2:]
1051
+ # print( vertices[-2:])
1052
+ # print( result[-2:])
1058
1053
1059
1054
# return mpath.Path(result, codes)
1060
1055
@@ -1068,12 +1063,13 @@ def drag_pan(self, button, key, x, y):
1068
1063
# maxtd = td.max()
1069
1064
# interpolate = np.ceil(maxtd / halfpi)
1070
1065
1071
- # print "interpolate", interpolate
1066
+ # print( "interpolate", interpolate)
1072
1067
# if interpolate > 1.0:
1073
1068
# vertices = self.interpolate(vertices, interpolate)
1074
1069
1075
1070
# result = np.zeros((len(vertices) * 3 - 2, 2), float)
1076
- # codes = mpath.Path.CURVE4 * np.ones((len(vertices) * 3 - 2, ), mpath.Path.code_type)
1071
+ # codes = mpath.Path.CURVE4 * np.ones((len(vertices) * 3 - 2, ),
1072
+ # mpath.Path.code_type)
1077
1073
# result[0] = vertices[0]
1078
1074
# codes[0] = mpath.Path.MOVETO
1079
1075
@@ -1095,16 +1091,19 @@ def drag_pan(self, button, key, x, y):
1095
1091
1096
1092
# result[1::3, 0] = t0 + (tkappa * td_scaled)
1097
1093
# result[1::3, 1] = r0*hyp_kappa
1098
- # # result[1::3, 1] = r0 / np.cos(tkappa * td_scaled) # np.sqrt(r0*r0 + ravg_kappa*ravg_kappa)
1094
+ # # result[1::3, 1] = r0 / np.cos(tkappa * td_scaled)
1095
+ # # np.sqrt(r0*r0 + ravg_kappa*ravg_kappa)
1099
1096
1100
1097
# result[2::3, 0] = t1 - (tkappa * td_scaled)
1101
1098
# result[2::3, 1] = r1*hyp_kappa
1102
- # # result[2::3, 1] = r1 / np.cos(tkappa * td_scaled) # np.sqrt(r1*r1 + ravg_kappa*ravg_kappa)
1099
+ # # result[2::3, 1] = r1 / np.cos(tkappa * td_scaled)
1100
+ # # np.sqrt(r1*r1 + ravg_kappa*ravg_kappa)
1103
1101
1104
1102
# result[3::3, 0] = t1
1105
1103
# result[3::3, 1] = r1
1106
1104
1107
- # print vertices[:6], result[:6], t0[:6], t1[:6], td[:6], td_scaled[:6], tkappa
1105
+ # print(vertices[:6], result[:6], t0[:6], t1[:6], td[:6],
1106
+ # td_scaled[:6], tkappa)
1108
1107
# result = self.transform(result)
1109
1108
# return mpath.Path(result, codes)
1110
1109
# transform_path_non_affine = transform_path
0 commit comments