These days I’m playing a simple but interesting Pokemon with stats dataset. Unexpectedlly,the
matplotlib do not support the radar chart. And the matplotlib radar chart sample is totally a mass (186 lines, what the hell). After an afternoon’s work I implemented the radar chart in a much simple way (only 20 lines). Hope this blog could help someone who is try to draw the radar chart in Python.
(Or time to change to R? ;P)
Load libraries and pokemon dataset. Set the label of axis. (‘HP’, ‘Attack’, ‘Defense’, ‘Sp. Atk’, ‘Sp. Def’, ‘Speed’). Here we use the No.386 pokemon as an example to illustrate the chart.
Set the angle of polar axis. Here we need to use the
np.concatenate to draw a closed plot in radar chart
angles=np.linspace(0, 2*np.pi, len(labels), endpoint=False). # Set the angle
Here we should use the
fig.add_subplot rather than the
sns.plt.subplots().(notice the “s”). Because the
subplots doesn’t contain the argument “polar”. We can only set the polar axis by
Then draw the plot as the frame and fill in the surrounded area by
fill(). At the end set the label of axis and the title then everything done.
Here is the stats radar chart: