Skip to content

Commit 202f40f

Browse files
committed
ENH: Allow setting angle limits on PolarAxes.
Setting angular limits allows one to create "wedges" instead of a full circle or annulus.
1 parent cbaee4a commit 202f40f

File tree

3 files changed

+352
-86
lines changed

3 files changed

+352
-86
lines changed

examples/api/radar_chart.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,10 @@ def radar_factory(num_vars, frame='circle'):
3737
"""
3838
# calculate evenly-spaced axis angles
3939
theta = np.linspace(0, 2*np.pi, num_vars, endpoint=False)
40-
# rotate theta such that the first axis is at the top
41-
theta += np.pi/2
4240

4341
def draw_poly_patch(self):
44-
verts = unit_poly_verts(theta)
42+
# rotate theta such that the first axis is at the top
43+
verts = unit_poly_verts(theta + np.pi / 2)
4544
return plt.Polygon(verts, closed=True, edgecolor='k')
4645

4746
def draw_circle_patch(self):
@@ -60,6 +59,11 @@ class RadarAxes(PolarAxes):
6059
# define draw_frame method
6160
draw_patch = patch_dict[frame]
6261

62+
def __init__(self, *args, **kwargs):
63+
super(RadarAxes, self).__init__(*args, **kwargs)
64+
# rotate plot such that the first axis is at the top
65+
self.set_theta_zero_location('N')
66+
6367
def fill(self, *args, **kwargs):
6468
"""Override fill so that line is closed by default"""
6569
closed = kwargs.pop('closed', True)
@@ -93,7 +97,7 @@ def _gen_axes_spines(self):
9397

9498
# spine_type must be 'left', 'right', 'top', 'bottom', or `circle`.
9599
spine_type = 'circle'
96-
verts = unit_poly_verts(theta)
100+
verts = unit_poly_verts(theta + np.pi / 2)
97101
# close off polygon by repeating first vertex
98102
verts.append(verts[0])
99103
path = Path(verts)

0 commit comments

Comments
 (0)