I am trying to plot arrows in a polar plot in matplotlib. I shall have 2 sets, one set points towards the center of the plot, I can get it easily; one set should tangent to the circle of radius r at the point considered. Both length should be a function of the angle theta.
I can get there by some cumbersome trigonometric consideration for the second set, but I was wondering if there would be a more elegant (and readable) way to do so. Especially as this is for a demo for students.
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
matplotlib.rcParams['figure.figsize'] = (8,8)
theta=np.linspace(0,2*np.pi,13)
rayon=np.linspace(R,R,13)
ax = plt.subplot(111, projection='polar')
ax.plot(theta, rayon,'.',markersize=10)
ax.set_rmax(0.6)
plt.arrow(theta[1], 0.5, 0, -0.25, width = 0.015, edgecolor = 'red', lw = 3,head_width=0.1, head_length=0.05)
l=.5
plt.arrow(theta[1], 0.5, np.arctan(l/.5), (np.sqrt(.5**2+l**2)-.5), width = 0.015,
edgecolor = 'green', lw = 3,head_width=0.1, head_length=0.05)
plt.show()