I want to place some text on a radius of a polar plot. When using the default theta zero location and direction it works as expected
fig = plt.figure(figsize=(6,6))
ax = fig.add_subplot(111, polar=True)
ax.set_yticklabels("")
ax.annotate('test',
xy=(np.deg2rad(90), 0.5),
fontsize=15,
rotation=90)
However this fails when changing the direction
fig = plt.figure(figsize=(6,6))
ax = fig.add_subplot(111, polar=True)
ax.set_theta_zero_location("N")
ax.set_theta_direction(-1)
ax.set_yticklabels("")
ax.annotate('test',
xy=(np.deg2rad(90), 0.5),
fontsize=15,
rotation=90)
It seems that the x and y are correct but the rotation angle is not. In theory, the transformation between clockwise and anti-clockwise should bring theta into -theta but that obviously does not work here. I have tried any possible transformation but it seems that something weird is happening..
What am I missing?
The rotation angle will follow the opposite of the position angle, starting from 90 (at position 0 you have an angle of 90°). Furthermore you can take
angle % 180
to avoid having text upside down:Output for
angle=135
: