首页 > 解决方案 > 如何在 matplotlib 中从图形中移动标签?

问题描述

我正在尝试从图表中移动那些混合到该图表中的标签(如财务信息、网络信息)。另外,我想在中心添加 0 作为标签。

图形

labels = df1.columns
stats = df1.loc[0, labels].values
angles = np.linspace(0, 2 * np.pi, len(labels), endpoint=False)  # Set the angle
# close the plot
stats = np.concatenate((stats, [stats[0]]))
angles = np.concatenate((angles, [angles[0]]))

fig2 = plt.figure(figsize=(6, 5))
ax = fig2.add_subplot(111,projection='polar')  # Set polar axis
ax.plot(angles, stats, 'o-', linewidth=1,color='#b1282e')
ax.fill(angles, stats, alpha=0.70,color='#b1282e')  # Fulfill the area

ax.set_thetagrids(angles * 180 / np.pi, labels)  # Set the label for each axis
ax.grid(True)
plt.show()

标签: pythonpandasmatplotlib

解决方案


推荐阅读