@@ -240,6 +240,39 @@ def zoom(self, direction):
240
240
return self .base .zoom (direction )
241
241
242
242
243
+ class ThetaAxis (maxis .XAxis ):
244
+ """
245
+ A theta Axis.
246
+
247
+ This overrides certain properties of an `XAxis` to provide special-casing
248
+ for an angular axis.
249
+ """
250
+ __name__ = 'thetaaxis'
251
+ axis_name = 'theta'
252
+
253
+ def _get_tick (self , major ):
254
+ if major :
255
+ tick_kw = self ._major_tick_kw
256
+ else :
257
+ tick_kw = self ._minor_tick_kw
258
+ return maxis .XTick (self .axes , 0 , '' , major = major , ** tick_kw )
259
+
260
+ def _wrap_locator_formatter (self ):
261
+ self .set_major_locator (ThetaLocator (self .get_major_locator ()))
262
+ self .set_major_formatter (ThetaFormatter())
263
+ self .isDefault_majloc = True
264
+ self .isDefault_majfmt = True
265
+
266
+ def cla (self ):
267
+ maxis .XAxis .cla (self )
268
+ self .set_ticks_position ('none' )
269
+ self ._wrap_locator_formatter ()
270
+
271
+ def _set_scale (self , value , ** kwargs ):
272
+ maxis .XAxis ._set_scale (self , value , ** kwargs )
273
+ self ._wrap_locator_formatter ()
274
+
275
+
243
276
class RadialLocator (mticker .Locator ):
244
277
"""
245
278
Used to locate radius ticks.
@@ -284,6 +317,38 @@ def view_limits(self, vmin, vmax):
284
317
return mtransforms .nonsingular (min (0 , vmin ), vmax )
285
318
286
319
320
+ class RadialAxis (maxis .YAxis ):
321
+ """
322
+ A radial Axis.
323
+
324
+ This overrides certain properties of a `YAxis` to provide special-casing
325
+ for a radial axis.
326
+ """
327
+ __name__ = 'radialaxis'
328
+ axis_name = 'radius'
329
+
330
+ def _get_tick (self , major ):
331
+ if major :
332
+ tick_kw = self ._major_tick_kw
333
+ else :
334
+ tick_kw = self ._minor_tick_kw
335
+ return maxis .YTick (self .axes , 0 , '' , major = major , ** tick_kw )
336
+
337
+ def _wrap_locator_formatter (self ):
338
+ self .set_major_locator (RadialLocator (self .get_major_locator (),
339
+ self .axes ))
340
+ self .isDefault_majloc = True
341
+
342
+ def cla (self ):
343
+ maxis .YAxis .cla (self )
344
+ self .set_ticks_position ('none' )
345
+ self ._wrap_locator_formatter ()
346
+
347
+ def _set_scale (self , value , ** kwargs ):
348
+ maxis .YAxis ._set_scale (self , value , ** kwargs )
349
+ self ._wrap_locator_formatter ()
350
+
351
+
287
352
def _is_full_circle_deg (thetamin , thetamax ):
288
353
"""
289
354
Determine if a wedge (in degrees) spans the full circle.
@@ -397,38 +462,27 @@ def cla(self):
397
462
398
463
self .title .set_y (1.05 )
399
464
400
- self .xaxis .set_major_formatter (self .ThetaFormatter ())
401
- self .xaxis .isDefault_majfmt = True
402
465
start = self .spines .get ('start' , None )
403
466
if start :
404
467
start .set_visible (False )
405
468
end = self .spines .get ('end' , None )
406
469
if end :
407
470
end .set_visible (False )
408
471
self .set_xlim (0.0 , 2 * np .pi )
409
- self .xaxis .set_major_locator (
410
- self .ThetaLocator (self .xaxis .get_major_locator ()))
411
472
412
473
self .grid (rcParams ['polaraxes.grid' ])
413
- self .xaxis .set_ticks_position ('none' )
414
474
inner = self .spines .get ('inner' , None )
415
475
if inner :
416
476
inner .set_visible (False )
417
- self .yaxis .set_ticks_position ('none' )
418
- # Why do we need to turn on yaxis tick labels, but
419
- # xaxis tick labels are already on?
420
- self .yaxis .set_tick_params (label1On = True )
421
- self .yaxis .set_major_locator (
422
- self .RadialLocator (self .yaxis .get_major_locator (), self ))
423
477
424
478
self .set_rorigin (None )
425
479
self .set_theta_offset (self ._default_theta_offset )
426
480
self .set_theta_direction (self ._default_theta_direction )
427
481
428
482
def _init_axis (self ):
429
483
"move this out of __init__ because non-separable axes don't use it"
430
- self .xaxis = maxis . XAxis (self )
431
- self .yaxis = maxis . YAxis (self )
484
+ self .xaxis = ThetaAxis (self )
485
+ self .yaxis = RadialAxis (self )
432
486
# Calling polar_axes.xaxis.cla() or polar_axes.xaxis.cla()
433
487
# results in weird artifacts. Therefore we disable this for
434
488
# now.
0 commit comments