代码
import numpy as np
import matplotlib.pyplot as plt
labels = np.array(['热量', '蛋白质', '钠', '碳水化合物', '脂肪'])
dataLength = 5
data = np.array([0.82, 0.34, 0.6, 0.44, 0.7])
angles = np.linspace(0, 2*np.pi, dataLength, endpoint=False)
data = np.concatenate((data, [data[0]]))
angles = np.concatenate((angles, [angles[0]]))
fig = plt.figure()
ax = fig.add_subplot(111, polar=True)
ax.plot(angles, data, 'bo-', linewidth=1)
ax.fill(angles, data, facecolor='m', alpha=0.3)
ax.set_thetagrids(angles * 180/np.pi, labels, fontproperties="SimHei")
ax.set_title("乐事薯片成分分析", va='baseline', fontproperties="SimHei")
ax.set_rlim(0, 1)
ax.grid(True)
plt.show()
运行结果
