python - Polar (Windrose) yticklabel 对齐

标签 python matplotlib label polar-coordinates

到目前为止,我一直在尝试移动 yticklabel,但没有成功。无论verticalalignmenthorizo​​ntalalignment 是什么,yticklabel 的位置(在本例中为 0.5、1.0、1.5)始终相同。

我想把它放在水平线以下。更改rlabel将旋转标签,我只想将它们转换到线下方。

import numpy
from windrose import WindroseAxes
import matplotlib.pyplot as plt

rose_angle = [25, 45, 45, 90, 125, 142, 165]
damage = [1, 1, 3, 1, 2, 1.3, 3]
ax = WindroseAxes.from_ax()
viridis = plt.get_cmap('viridis')

ax.bar(rose_angle, damage, normed=False, opening=0.8, edgecolor='white', nsector=36, cmap=viridis, bins=[1., 1.5, 2.01])

ax.set_xticklabels(['90$^0$', '', '0$^0$', '', '', '', '0$^0$', ''])
ax.set_theta_zero_location("N")
ax.set_rlabel_position(270)  # get radial labels away from plotted line
ax.set_legend(labels = ['Tensile Dominant', 'Shear Dominant', 'Mixed Mode'], title="Failure Mode", bbox_to_anchor=(0.005 , 0.95), loc='center')

ax.set_yticks(numpy.arange(0.5, 2, step=0.5))
ax.set_yticklabels(numpy.arange(0.5, 2, step=0.5), verticalalignment='bottom', horizontalalignment='right')

plt.suptitle("Time Step")

plt.show()

垂直对齐=底部 VA = BOTTOM

垂直对齐=顶部 VA = TOP

最佳答案

被忽略的极坐标网格标签的对齐方式是 an issue在 matplotlib 2.2.2 中。已通过 https://github.com/matplotlib/matplotlib/pull/10792 修复因此从 matplotlib 2.2.3 开始可用。

关于python - Polar (Windrose) yticklabel 对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52955288/

相关文章:

python - 需要从文本文件创建列表

android - 无法在设置中更改 Android 应用名称

html - 辅助功能:如何为一个 INPUT 项正确使用多个 LABEL 元素(通过 ARIA 等)?

python - Mechanize python嵌套形式错误

python - Pandas 情节时间序列 ['numpy.ndarray' 对象没有属性 'find']

python - 如何让Fabric在得到退出状态: 1?后继续运行下一条命令

python - 更改mapltolib图中的 Axis

python - 如何使用 matplotlib 从数据帧创建简单的动画图

python - 使用 matplotlib 平滑 imshow 图

javascript - 无法更改 <label> 文本颜色