Draw lines on the graph

Hi,

I'm plotting some graphs with matplotlib and I would like to do the following:

Draw lines on the graph (match two points to show the up-trend or
down-trend line of a stock). I would want the lines drawn by me on the
graph resize accordingly as one zooms in or out of the graph.

Can anyone kindly point me to the API's or examples on how to do this?
I have tried looking but couldn't get it working.

Thanks,
Hitesh

Hi,

If I understand right you want to redraw new trend lines when you zoom in (recalculated for the visible data). You then have to use event callbacks which usage example is shown here (view limits change example):

http://matplotlib.sourceforge.net/examples/event_handling/viewlims.html

For one trend line it's relatively easy, you just recalculate the beginning and the end points. In the case when you have to guess how many lines you have to use it begins to be quite tricky if you haven't got a proper algorithm for that.

Hope it helps.

Cheers,

Jakub

ยทยทยท

On 21 Feb 2010, at 08:48, logan wrote:

Hi,

I'm plotting some graphs with matplotlib and I would like to do the following:

Draw lines on the graph (match two points to show the up-trend or
down-trend line of a stock). I would want the lines drawn by me on the
graph resize accordingly as one zooms in or out of the graph.

Can anyone kindly point me to the API's or examples on how to do this?
I have tried looking but couldn't get it working.

Thanks,
Hitesh

------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users