I am the author of that SO post you link to and have removed the first sentence because it was confusing (I was apologizing for having made an error, not saying that it could not be done at some point in the past).
If you only want to move around a few vectors, using ax.quiver
is probably overkill in terms of complexity. I suggest instead you look at ax.annotate
but with no text (which is a bit odd, but it works)
To demonstrate this I wrote a crude matplotclock:
import matplotlib.pyplot as plt
import numpy as np
import matplotlib.patches as mpatches
from matplotlib.animation import FuncAnimation
fig, ax = plt.subplots()
an1 = ax.annotate("", xy=(0, 1), xytext=(0, 0), arrowprops={"facecolor": "black"})
an2 = ax.annotate("", xy=(0, 1), xytext=(0, 0), arrowprops={"facecolor": "blue"})
an3 = ax.annotate("", xy=(0, 1), xytext=(0, 0), arrowprops={"facecolor": "red"})
face = mpatches.Circle((0, 0), radius=1, zorder=-1, color="gray")
ax.add_patch(face)
ax.set_xlim(-3, 3)
ax.set_ylim(-3, 3)
ax.set_aspect("equal")
def anim(j):
# compute the new center
center = np.array(np.unravel_index(j % 100, (10, 10))) / 10 - 0.5
# set the clock face to that center
face.set_center(center)
# advance time 15 degree / frame
j *= 15
# compute the angles of the second, minute, and hour hands
s = np.deg2rad(j)
m = np.deg2rad(j / 60)
h = np.deg2rad(j / (60 * 60))
# adjust the end of the annotation with the arrow on it
an1.xy = center + (np.sin(h), np.cos(h))
an2.xy = center + (np.sin(m), np.cos(m))
an3.xy = center + (np.sin(s), np.cos(s))
# adjust the end of the annotation without the arrow
an1.set_position(center)
an2.set_position(center)
an3.set_position(center)
# return the Artists so blitting works
return [an1, an2, an3, face]
anim = FuncAnimation(fig, anim, frames=60, blit=True)
plt.show()
For more details about how you can customize the annotation see https://matplotlib.org/3.1.1/tutorials/text/annotations.html#sphx-glr-tutorials-text-annotations-py and https://matplotlib.org/3.1.1/api/_as_gen/matplotlib.axes.Axes.annotate.html#matplotlib.axes.Axes.annotate