what is the right way to draw an arrow that loops back to point to its origin in matplotlib? i tried:
plt.figure()
plt.xlim([0, 1])
plt.ylim([0, 1])
plt.annotate("", xy=(0.6, 0.9),
xycoords="figure fraction",
xytext = (0.6, 0.8),
textcoords="figure fraction",
fontsize = 10, \
color = "k",
arrowprops=dict(edgecolor='black',
connectionstyle="angle,angleA=-180,angleB=45",
arrowstyle = '<|-',
facecolor="k",
linewidth=1,
shrinkA = 0,
shrinkB = 0))
plt.show()
this doesn't give the right result:
the connectionstyle
arguments are hard to follow from this page (http://matplotlib.org/users/annotations_guide.html).
i'm looking for is something like this or this:
update: the answer linked to does not show how do this with plt.annotate
which has other features i want to use. the proposal to use $\circlearrowleft$
marker is not a real solution.
Plot x and y with color=red and linewidth = 1. Use arrow method to add an arrow to the axes. The first two values in the arguments are the coordinates of the arrow base and the next two values are for the length of the arrow along X and Y direction. To display the figure, use show() method.
We can add arrows to an annotation in Matplotlib by passing the arrowprops argument to the ax. annotate(~) method.
The clf() function in pyplot module of matplotlib library is used to clear the current figure.
Try this:
import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.add_subplot(1,1,1)
ax.set_xlim(1,3)
ax.set_ylim(1,3)
ax.plot([2.5],[2.5],marker=r'$\circlearrowleft$',ms=100)
plt.show()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With