Polar(Windrose)yticklabel对齐方式

时间:2018-10-23 18:07:36

标签: python matplotlib label polar-coordinates

到目前为止,我一直在尝试移动yticklabel,但未成功。无论verticalaligmenthorizontalalignment是什么,ytick标签的位置(在本例中为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

verticalaligment = top VA = TOP

1 个答案:

答案 0 :(得分:1)

在matplotlib 2.2.2中,被忽略的极坐标标签的对齐方式为an issue。它已通过https://github.com/matplotlib/matplotlib/pull/10792进行了修复,因此可以从matplotlib 2.2.3上获得。