python - 如何在 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()
解决方案
推荐阅读
- c++ - 重新分配指针如何影响多态性
- python - Formatting numpy arrays with black
- html - 如何在不跳过一行的情况下打印php
- java - Java 'final' instance variable - visibility and propagation of variable's internal state
- javascript - POST 使用 javascript 失败,但使用 IIS 托管网页上的表单成功
- python - Parsing HTML with Python. requests and LXML
- .htaccess - .htaccess 文件,RewriteRule 部分工作
- python-3.x - 从 Windows 系统上的路径获取文件名和参数(使用 Python)
- visual-studio-code - 如何撤消关闭选项卡 VsCode 中的更改
- reactjs - 加载第一个 localhost 时,它没有显示包含我拥有的代码的组件