WOW - I delayed my bed time when I saw this come in.
It certainly seems to do what I want in your example.

Tomorrow at work I'll try and fit it into my frame work, and see what 
happens.

Thanks a lot,
Steve


John Hunter wrote:
> On 6/14/07, Stephen George <[EMAIL PROTECTED]> wrote:
>
>> So my questions.
>> 1) Is there a way to get the indexes (not the values) of the portion of
>> the line actually showing on screen
>> 2) Is there a way to get a copy of the portion of the data displayed on
>> screen (in a new array) ?
>> 3) Is there a better way of linking psd so it performs the spectrum
>> analysis only on the portion of data on screen?
>
> I just updated the span selector example in svn to show you how to do
> this.  You select a region in the upper graph with a mouse drag, and
> it plots the detail of the selected region in the lower graph.  You
> should be able to modify this to plot the psd of the selected region,
> etc....
>
> #!/usr/bin/env python
> """
> The SpanSelector is a mouse widget to select a xmin/xmax range and 
> plot the
> detail view of the selected region in the lower axes
> """
> import numpy as npy
> from pylab import figure, show
> from matplotlib.widgets import SpanSelector
>
> fig = figure(figsize=(8,6))
> ax = fig.add_subplot(211, axisbg='#FFFFCC')
>
> x = npy.arange(0.0, 5.0, 0.01)
> y = npy.sin(2*npy.pi*x) + 0.5*npy.random.randn(len(x))
>
> ax.plot(x, y, '-')
> ax.set_ylim(-2,2)
> ax.set_title('Press left mouse button and drag to test')
>
> ax2 = fig.add_subplot(212, axisbg='#FFFFCC')
> line2, = ax2.plot(x, y, '-')
>
>
> def onselect(xmin, xmax):
>    indmin, indmax = npy.searchsorted(x, (xmin, xmax))
>    indmax = min(len(x)-1, indmax)
>
>    thisx = x[indmin:indmax]
>    thisy = y[indmin:indmax]
>    line2.set_data(thisx, thisy)
>    ax2.set_xlim(thisx[0], thisx[-1])
>    ax2.set_ylim(thisy.min(), thisy.max())
>    fig.canvas.draw()
>
> # set useblit True on gtkagg for enhanced performance
> span = SpanSelector(ax, onselect, 'horizontal', useblit=False,
>                    rectprops=dict(alpha=0.5, facecolor='red') )
>
>
> show()
>
>>
>> *
>> *Thanks for your help
>> Steve
>>
>> ------------------------------------------------------------------------- 
>>
>> This SF.net email is sponsored by DB2 Express
>> Download DB2 Express C - the FREE version of DB2 express and take
>> control of your XML. No limits. Just data. Click to get it now.
>> http://sourceforge.net/powerbar/db2/
>> _______________________________________________
>> Matplotlib-users mailing list
>> Matplotlib-users@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>
> ------------------------------------------------------------------------
>
> #!/usr/bin/env python
> """
> The SpanSelector is a mouse widget to select a xmin/xmax range and plot the
> detail view of the selected region in the lower axes
> """
> import numpy as npy
> from pylab import figure, show
> from matplotlib.widgets import SpanSelector
>
> fig = figure(figsize=(8,6))
> ax = fig.add_subplot(211, axisbg='#FFFFCC')
>
> x = npy.arange(0.0, 5.0, 0.01)
> y = npy.sin(2*npy.pi*x) + 0.5*npy.random.randn(len(x))
>
> ax.plot(x, y, '-')
> ax.set_ylim(-2,2)
> ax.set_title('Press left mouse button and drag to test')
>
> ax2 = fig.add_subplot(212, axisbg='#FFFFCC')
> line2, = ax2.plot(x, y, '-')
>
>
> def onselect(xmin, xmax):
>     indmin, indmax = npy.searchsorted(x, (xmin, xmax))
>     indmax = min(len(x)-1, indmax)
>
>     thisx = x[indmin:indmax]
>     thisy = y[indmin:indmax]
>     line2.set_data(thisx, thisy)
>     ax2.set_xlim(thisx[0], thisx[-1])
>     ax2.set_ylim(thisy.min(), thisy.max())
>     fig.canvas.draw()
>
> # set useblit True on gtkagg for enhanced performance
> span = SpanSelector(ax, onselect, 'horizontal', useblit=False,
>                     rectprops=dict(alpha=0.5, facecolor='red') )
>
>
> show()
>   


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to