I use the following code to draw nightingale rose chart:
mydata = pd.DataFrame(dict(model=["1", "2", "3", "4", "5", "6", "7", "8"], auc_roc=[99.7, 80.2, 85.3, 87.9, 89.2, 88.6, 91.0, 96.6]))
n_row = mydata.shape[0]
angle = np.arange(0, 2*np.pi, 2*np.pi/n_row)
radius = np.array(mydata.auc_roc)
fig = plt.figure(figsize=(4, 4), dpi=180)
ax = fig.add_axes([0.1, 0.1, 0.8, 0.8], polar=True)
ax.set_theta_offset(np.pi/2-np.pi/n_row)
ax.set_theta_direction(-1)
ax.set_rlabel_position(360-180/n_row)
# colors = ['#FFB300', '#803E75', '#FF6800', '#A6BDD7', '#C10020', '#CEA262', '#817066', '#007D34']
cmap=cm.get_cmap('Reds', n_col)
all_color=[colors.rgb2hex(cmap(i)[:8]) for i in range(cmap.N)]
bars = ax.bar(angle, radius, color=all_color, edgecolor="k", width=0.90, alpha=0.9)
for bar in bars:
height = bar.get_height()
ax.text(bar.get_x() + bar.get_width()/2.0, height, f'{height:.1f}', ha='center', va='bottom')
plt.xticks(angle, labels=mydata.model, size=8)
plt.ylim(0, 105)
plt.yticks(np.arange(0, 100, 10))
plt.grid(which='major', axis="x", linestyle='-', linewidth='0.5', color='gray', alpha=0.5)
plt.grid(which='major', axis="y", linestyle='-', linewidth='0.5', color='gray', alpha=0.5)
plt.show()
This figure is shown as:
enter image description here
However, each category has the overlapped content in the figure. How to solve it?
New contributor
Jiayue Qiu is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.