My understanding is that you're asking what to do when the arrowhead is off the plot. There are a few options:
- You can draw the arrow up to the boundary and use a type of arrow head that indicates that it's not the true end of the arrow, such as a half arrow head,
"shape"="left"
, or open vs. closed, etc. - You can draw the arrowhead midway along the arrow, like is done for a streamline. I don't know a command for this in mpl, but you could easily do it using two arrows, or just plotting a line and the head of an arrow, etc.
Edit:
For completeness, I'll add my take on a #2. Here's I plot the line, and then plot the arrow over the line, and the arrowhead can be plotted anywhere along the line and in controlled by f
(between 0 and 1). The example shows a few lines plotted for f
ranging from 0
to .1
.
import numpy as np
import pylab as plt
def arrow_mh(v4, color, f=.5):
x0, y0, x1, y1 = v4
line = plt.plot([x0, x1], [y0, y1], color=color)
f = max(f, .0001)
dx = f*(x1-x0)
dy = f*(y1-y0)
a = plt.arrow(x0, y0, dx, dy,
color=color,head_width=0.05, head_length=0.1)
def arrow_segment(AB):
for idx in range(0,len(AB)):
arrow_mh(AB[idx], 'blue', .01*(9-idx))
plt.xlim(0, 1)
plt.ylim(0, 1)
plt.show()
AB = np.array([[.1*i, .1, .5, 4] for i in range(10)])
arrow_segment(AB)