Skip to content

Commit 24cd72d

Browse files
committed
ENH: Allow offsetting PolarAxes' zero location.
Let the user specify an arbitrary zero location with reference to the usual cardinal points. This can be a bit more intuitive than requiring the offset in radians.
1 parent 3e9b656 commit 24cd72d

File tree

5 files changed

+604
-598
lines changed

5 files changed

+604
-598
lines changed

lib/matplotlib/projections/polar.py

+9-3
Original file line numberDiff line numberDiff line change
@@ -664,12 +664,18 @@ def get_theta_offset(self):
664664
"""
665665
return self._theta_offset.get_matrix()[0, 2]
666666

667-
def set_theta_zero_location(self, loc):
667+
def set_theta_zero_location(self, loc, offset=0.0):
668668
"""
669669
Sets the location of theta's zero. (Calls set_theta_offset
670670
with the correct value in radians under the hood.)
671671
672-
May be one of "N", "NW", "W", "SW", "S", "SE", "E", or "NE".
672+
loc : str
673+
May be one of "N", "NW", "W", "SW", "S", "SE", "E", or "NE".
674+
675+
offset : float, optional
676+
An offset in degrees to apply from the specified `loc`. **Note:**
677+
this offset is *always* applied counter-clockwise regardless of
678+
the direction setting.
673679
"""
674680
mapping = {
675681
'N': np.pi * 0.5,
@@ -680,7 +686,7 @@ def set_theta_zero_location(self, loc):
680686
'SE': np.pi * 1.75,
681687
'E': 0,
682688
'NE': np.pi * 0.25 }
683-
return self.set_theta_offset(mapping[loc])
689+
return self.set_theta_offset(mapping[loc] + np.deg2rad(offset))
684690

685691
def set_theta_direction(self, direction):
686692
"""
Binary file not shown.

0 commit comments

Comments
 (0)