@@ -63,7 +63,7 @@ def transform(self, tr):
63
63
64
64
t *= theta_direction
65
65
t += theta_offset
66
-
66
+
67
67
if rmin != 0 :
68
68
r = r - rmin
69
69
mask = r < 0
@@ -150,7 +150,7 @@ def transform(self, xy):
150
150
rmin = 0
151
151
theta_offset = 0
152
152
theta_direction = 1
153
-
153
+
154
154
x = xy [:, 0 :1 ]
155
155
y = xy [:, 1 :]
156
156
r = np .sqrt (x * x + y * y )
@@ -161,7 +161,7 @@ def transform(self, xy):
161
161
theta *= theta_direction
162
162
163
163
r += rmin
164
-
164
+
165
165
return np .concatenate ((theta , r ), 1 )
166
166
transform .__doc__ = Transform .transform .__doc__
167
167
@@ -230,7 +230,6 @@ def __init__(self, *args, **kwargs):
230
230
interpolation.
231
231
"""
232
232
233
- self ._rpad = 0.05
234
233
self .resolution = kwargs .pop ('resolution' , None )
235
234
if self .resolution not in (None , 1 ):
236
235
warnings .warn (
@@ -262,7 +261,7 @@ def cla(self):
262
261
263
262
self .set_theta_offset (0 )
264
263
self .set_theta_direction (1 )
265
-
264
+
266
265
def _init_axis (self ):
267
266
"move this out of __init__ because non-separable axes don't use it"
268
267
self .xaxis = maxis .XAxis (self )
@@ -320,21 +319,10 @@ def _set_lim_and_transforms(self):
320
319
Affine2D ().scale (np .pi * 2.0 , 1.0 ) +
321
320
self .transData )
322
321
# The r-axis labels are put at an angle and padded in the r-direction
323
- self ._r_label1_position = ScaledTranslation (
324
- 22.5 , self ._rpad ,
325
- blended_transform_factory (
326
- Affine2D (), BboxTransformToMaxOnly (self .viewLim )))
327
- self ._yaxis_text1_transform = (
328
- self ._r_label1_position +
329
- Affine2D ().scale (1.0 / 360.0 , 1.0 ) +
330
- self ._yaxis_transform
331
- )
332
- self ._r_label2_position = ScaledTranslation (
333
- 22.5 , - self ._rpad ,
334
- blended_transform_factory (
335
- Affine2D (), BboxTransformToMaxOnly (self .viewLim )))
336
- self ._yaxis_text2_transform = (
337
- self ._r_label2_position +
322
+ self ._r_label_position = ScaledTranslation (
323
+ 22.5 , 0.0 , Affine2D ())
324
+ self ._yaxis_text_transform = (
325
+ self ._r_label_position +
338
326
Affine2D ().scale (1.0 / 360.0 , 1.0 ) +
339
327
self ._yaxis_transform
340
328
)
@@ -354,10 +342,26 @@ def get_yaxis_transform(self,which='grid'):
354
342
return self ._yaxis_transform
355
343
356
344
def get_yaxis_text1_transform (self , pad ):
357
- return self ._yaxis_text1_transform , 'center' , 'center'
345
+ angle = self ._r_label_position .to_values ()[4 ]
346
+ if angle < 90. :
347
+ return self ._yaxis_text_transform , 'bottom' , 'left'
348
+ elif angle < 180. :
349
+ return self ._yaxis_text_transform , 'bottom' , 'right'
350
+ elif angle < 270. :
351
+ return self ._yaxis_text_transform , 'top' , 'right'
352
+ else :
353
+ return self ._yaxis_text_transform , 'top' , 'left'
358
354
359
355
def get_yaxis_text2_transform (self , pad ):
360
- return self ._yaxis_text2_transform , 'center' , 'center'
356
+ angle = self ._r_label_position .to_values ()[4 ]
357
+ if angle < 90. :
358
+ return self ._yaxis_text_transform , 'top' , 'right'
359
+ elif angle < 180. :
360
+ return self ._yaxis_text_transform , 'top' , 'left'
361
+ elif angle < 270. :
362
+ return self ._yaxis_text_transform , 'bottom' , 'left'
363
+ else :
364
+ return self ._yaxis_text_transform , 'bottom' , 'right'
361
365
362
366
def _gen_axes_patch (self ):
363
367
return Circle ((0.5 , 0.5 ), 0.5 )
@@ -407,7 +411,7 @@ def set_theta_zero_location(self, loc):
407
411
'E' : 0 ,
408
412
'NE' : np .pi * 0.25 }
409
413
return self .set_theta_offset (mapping [loc ])
410
-
414
+
411
415
def set_theta_direction (self , direction ):
412
416
"""
413
417
Set the direction in which theta increases.
@@ -438,7 +442,7 @@ def get_theta_direction(self):
438
442
Theta increases in the counterclockwise direction
439
443
"""
440
444
return self ._direction
441
-
445
+
442
446
def set_rlim (self , * args , ** kwargs ):
443
447
if 'rmin' in kwargs :
444
448
kwargs ['ymin' ] = kwargs .pop ('rmin' )
@@ -497,7 +501,7 @@ def set_thetagrids(self, angles, labels=None, frac=None, fmt=None,
497
501
return self .xaxis .get_ticklines (), self .xaxis .get_ticklabels ()
498
502
499
503
@docstring .dedent_interpd
500
- def set_rgrids (self , radii , labels = None , angle = None , rpad = None , fmt = None ,
504
+ def set_rgrids (self , radii , labels = None , angle = None , fmt = None ,
501
505
** kwargs ):
502
506
"""
503
507
Set the radial locations and labels of the *r* grids.
@@ -510,9 +514,6 @@ def set_rgrids(self, radii, labels=None, angle=None, rpad=None, fmt=None,
510
514
511
515
If *labels* is None, the built-in formatter will be used.
512
516
513
- *rpad* is a fraction of the max of *radii* which will pad each of
514
- the radial labels in the radial direction.
515
-
516
517
Return value is a list of tuples (*line*, *label*), where
517
518
*line* is :class:`~matplotlib.lines.Line2D` instances and the
518
519
*label* is :class:`~matplotlib.text.Text` instances.
@@ -536,13 +537,9 @@ def set_rgrids(self, radii, labels=None, angle=None, rpad=None, fmt=None,
536
537
elif fmt is not None :
537
538
self .yaxis .set_major_formatter (FormatStrFormatter (fmt ))
538
539
if angle is None :
539
- angle = self ._r_label1_position .to_values ()[4 ]
540
- if rpad is not None :
541
- self ._rpad = rpad
542
- self ._r_label1_position ._t = (angle , self ._rpad )
543
- self ._r_label1_position .invalidate ()
544
- self ._r_label2_position ._t = (angle , - self ._rpad )
545
- self ._r_label2_position .invalidate ()
540
+ angle = self ._r_label_position .to_values ()[4 ]
541
+ self ._r_label_position ._t = (angle , 0.0 )
542
+ self ._r_label_position .invalidate ()
546
543
for t in self .yaxis .get_ticklabels ():
547
544
t .update (kwargs )
548
545
return self .yaxis .get_gridlines (), self .yaxis .get_ticklabels ()
@@ -594,7 +591,7 @@ def can_pan(self) :
594
591
return True
595
592
596
593
def start_pan (self , x , y , button ):
597
- angle = self ._r_label1_position .to_values ()[4 ] / 180.0 * np . pi
594
+ angle = np . deg2rad ( self ._r_label_position .to_values ()[4 ])
598
595
mode = ''
599
596
if button == 1 :
600
597
epsilon = np .pi / 45.0
@@ -608,7 +605,7 @@ def start_pan(self, x, y, button):
608
605
rmax = self .get_rmax (),
609
606
trans = self .transData .frozen (),
610
607
trans_inverse = self .transData .inverted ().frozen (),
611
- r_label_angle = self ._r_label1_position .to_values ()[4 ],
608
+ r_label_angle = self ._r_label_position .to_values ()[4 ],
612
609
x = x ,
613
610
y = y ,
614
611
mode = mode
@@ -633,11 +630,16 @@ def drag_pan(self, button, key, x, y):
633
630
dt = dt0 * - 1.0
634
631
dt = (dt / np .pi ) * 180.0
635
632
636
- rpad = self ._rpad
637
- self ._r_label1_position ._t = (p .r_label_angle - dt , rpad )
638
- self ._r_label1_position .invalidate ()
639
- self ._r_label2_position ._t = (p .r_label_angle - dt , - rpad )
640
- self ._r_label2_position .invalidate ()
633
+ self ._r_label_position ._t = (p .r_label_angle - dt , 0.0 )
634
+ self ._r_label_position .invalidate ()
635
+
636
+ trans , vert1 , horiz1 = self .get_yaxis_text1_transform (0.0 )
637
+ trans , vert2 , horiz2 = self .get_yaxis_text2_transform (0.0 )
638
+ for t in self .yaxis .majorTicks + self .yaxis .minorTicks :
639
+ t .label1 .set_va (vert1 )
640
+ t .label1 .set_ha (horiz1 )
641
+ t .label2 .set_va (vert2 )
642
+ t .label2 .set_ha (horiz2 )
641
643
642
644
elif p .mode == 'zoom' :
643
645
startt , startr = p .trans_inverse .transform_point ((p .x , p .y ))
0 commit comments