In [ ]:
import matplotlib.pyplot as plt
import numpy as np
In [ ]:
#define a super hero (wonder woman)
attributes= ['Power', 'Speed', 'Strength', 'Intelligence', 'Flight']
values= [90, 80, 75, 90, 75]
values= values +[90]
values
Out[ ]:
[90, 80, 75, 90, 75, 90]
In [ ]:
#define angles
angles = np.linspace(0, 2*np.pi, 5, endpoint=False).tolist()
angles = angles+ [0]
angles
Out[ ]:
[0.0, 1.2566370614359172, 2.5132741228718345, 3.7699111843077517, 5.026548245743669, 0]
In [ ]:
values_flash=[95, 100, 90, 90, 65]
values_flash= values_flash +[95]
values_flash
Out[ ]:
[95, 100, 90, 90, 65, 95]
In [ ]:
#initialize the radar chart
plt.figure(figsize=(5,5))
ax= plt.subplot(polar=True)
#add attributes/features
plt.xticks(angles[:-1], attributes)
ax.set_rlabel_position(40)
plt.yticks([20,40,60,80,100], color="blue", alpha=0.8, size=7)
plt.ylim(0,100)
#add wonder woman info
ax.plot(angles, values, label='wonder woman',color='blue',linewidth=2, linestyle='--')
ax.fill(angles, values, alpha=0.4, facecolor='pink') #how to full in the area color
#add another superhero
ax.plot(angles, values_flash, label='flash',linewidth=2, color='orange', linestyle='--')
ax.fill(angles, values_flash, alpha=0.2, facecolor='lightgreen')
plt.legend(loc='upper left')
plt.show()
In [ ]: