Catherine Thwaites, on 2011-03-23 10:10,  wrote:
> I have tried to search for the answer but have not found anything useful so
> forgive me if this has been answered before.
> I want to change the linestyle of a regular plot to an arrow, in the
> direction of the data in the tuple. So in this script below I would like an
> arrow head pointing to the next marker.
> There does not seem to be a line style to do it, but is there a way I can
> add the head at the correct end of the line?

Hi Catherine,

here's one way to get the type of plot you desire, and you might
also consider using a series of annotation with arrows to get a
similar effect:


import numpy as np
import matplotlib.pyplot as plt
import matplotlib as mpl

labels=('91','92','93','94','95')
data1 = np.array([2500, 3000, 3500, 3000, 2700])
data2 = np.array([200, 250, 270, 320, 250])

fig = plt.figure()
ax = fig.add_subplot(111)
# the next line is only use to set the proper lims, 
p = ax.plot(data1, data2, 'bo', linestyle='-', markersize=3, alpha=0)
for x,y,dx,dy in zip(data1[:-1],data2[:-1], np.diff(data1), np.diff(data2)):
    ax.arrow(x,y,dx,dy, head_width=10, length_includes_head=True)
ax.set_ylim(0, 350)

for i, label in enumerate(labels):
    x_loc = data1[i]
    y_loc = data2[i]
    txt = ax.annotate(label, xy=(x_loc, y_loc), size=8,
        xytext=(-10, 10), textcoords='offset points',
        arrowprops=None)

plt.axis('equal')
plt.show()

best,
-- 
Paul Ivanov
314 address only used for lists,  off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 

Attachment: signature.asc
Description: Digital signature

------------------------------------------------------------------------------
Enable your software for Intel(R) Active Management Technology to meet the
growing manageability and security demands of your customers. Businesses
are taking advantage of Intel(R) vPro (TM) technology - will your software 
be a part of the solution? Download the Intel(R) Manageability Checker 
today! http://p.sf.net/sfu/intel-dev2devmar
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to