Skip to content

Polar limits enhancements #4699

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Aug 21, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
ENH: Allow setting angle limits on PolarAxes.
Setting angular limits allows one to create "wedges" instead of a full
circle or annulus.
  • Loading branch information
QuLogic committed Aug 16, 2017
commit 202f40f5025b9185f93c342add8522c346bb3697
12 changes: 8 additions & 4 deletions examples/api/radar_chart.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,10 @@ def radar_factory(num_vars, frame='circle'):
"""
# calculate evenly-spaced axis angles
theta = np.linspace(0, 2*np.pi, num_vars, endpoint=False)
# rotate theta such that the first axis is at the top
theta += np.pi/2

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

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

def __init__(self, *args, **kwargs):
super(RadarAxes, self).__init__(*args, **kwargs)
# rotate plot such that the first axis is at the top
self.set_theta_zero_location('N')

def fill(self, *args, **kwargs):
"""Override fill so that line is closed by default"""
closed = kwargs.pop('closed', True)
Expand Down Expand Up @@ -93,7 +97,7 @@ def _gen_axes_spines(self):

# spine_type must be 'left', 'right', 'top', 'bottom', or `circle`.
spine_type = 'circle'
verts = unit_poly_verts(theta)
verts = unit_poly_verts(theta + np.pi / 2)
# close off polygon by repeating first vertex
verts.append(verts[0])
path = Path(verts)
Expand Down
Loading