hi all,
i am trying to plot a series of arrows between points on a scatter
plot, using the following code:
import matplotlib.pyplot as plt
from matplotlib.patches import FancyArrowPatch
from numpy import *
from scipy import *
def plot_arrows(init_val, all_vals, c='k'):
plt.figure()
ax = plt.gca()
prev_val = init_val
for x, y in all_vals[1:]:
ax = plt.gca()
start_coord = prev_val
plt.scatter(start_coord[0], start_coord[1], c=c)
end_coord = (x, y)
ax.add_patch(FancyArrowPatch(start_coord, end_coord,
arrowstyle='->', edgecolor=c,
facecolor=c, mutation_scale=10))
prev_val = end_coord
plt.scatter(all_vals[-1][0], all_vals[-1][1], c=c)
points = rand(5,2)
init = [0, 0]
plot_arrows(init, points)
plt.show()
this usually works, but sometimes when i give it a set of points (not
necessarily ones generated randomly), then it gives me the error:
Library/Python/2.5/site-packages/matplotlib/bezier.pyc in
split_path_inout(path, inside, tolerence, reorder_inout)
265
266 if bezier_path is None:
--> 267 raise ValueError("The path does not seem to intersect
with the patch")
268
269 bp = zip(bezier_path[::2], bezier_path[1::2])
ValueError: The path does not seem to intersect with the patch
any idea what could be causing this? it seems like any arbitrary set
of points should work here, since you can always draw an arrow between
any two points.... not sure what is the root of this error. any help
would be really appreciated. thank you.