Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cc71742

Browse files
authored
Merge pull request #22458 from prohde/radar_chart_example
2 parents 190b6bd + f4f33f9 commit cc71742

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

examples/specialty_plots/radar_chart.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,22 @@ def radar_factory(num_vars, frame='circle'):
4242
# calculate evenly-spaced axis angles
4343
theta = np.linspace(0, 2*np.pi, num_vars, endpoint=False)
4444

45+
class RadarTransform(PolarAxes.PolarTransform):
46+
47+
def transform_path_non_affine(self, path):
48+
# Paths with non-unit interpolation steps correspond to gridlines,
49+
# in which case we force interpolation (to defeat PolarTransform's
50+
# autoconversion to circular arcs).
51+
if path._interpolation_steps > 1:
52+
path = path.interpolated(num_vars)
53+
return Path(self.transform(path.vertices), path.codes)
54+
4555
class RadarAxes(PolarAxes):
4656

4757
name = 'radar'
4858
# use 1 line segment to connect specified points
4959
RESOLUTION = 1
60+
PolarTransform = RadarTransform
5061

5162
def __init__(self, *args, **kwargs):
5263
super().__init__(*args, **kwargs)
@@ -175,7 +186,7 @@ def example_data():
175186
horizontalalignment='center', verticalalignment='center')
176187
for d, color in zip(case_data, colors):
177188
ax.plot(theta, d, color=color)
178-
ax.fill(theta, d, facecolor=color, alpha=0.25)
189+
ax.fill(theta, d, facecolor=color, alpha=0.25, label='_nolegend_')
179190
ax.set_varlabels(spoke_labels)
180191

181192
# add legend relative to top-left plot

0 commit comments

Comments
 (0)