rectangle_selector.py :  » Chart-Report » Matplotlib » matplotlib-0.99.1.1 » lib » mpl_examples » widgets » Python Open Source

Home
Python Open Source
1.3.1.2 Python
2.Ajax
3.Aspect Oriented
4.Blog
5.Build
6.Business Application
7.Chart Report
8.Content Management Systems
9.Cryptographic
10.Database
11.Development
12.Editor
13.Email
14.ERP
15.Game 2D 3D
16.GIS
17.GUI
18.IDE
19.Installer
20.IRC
21.Issue Tracker
22.Language Interface
23.Log
24.Math
25.Media Sound Audio
26.Mobile
27.Network
28.Parser
29.PDF
30.Project Management
31.RSS
32.Search
33.Security
34.Template Engines
35.Test
36.UML
37.USB Serial
38.Web Frameworks
39.Web Server
40.Web Services
41.Web Unit
42.Wiki
43.Windows
44.XML
Python Open Source » Chart Report » Matplotlib 
Matplotlib » matplotlib 0.99.1.1 » lib » mpl_examples » widgets » rectangle_selector.py
"""
Do a mouseclick somewhere, move the mouse to some destination, release
the button.  This class gives click- and release-events and also draws
a line or a box from the click-point to the actual mouseposition
(within the same axes) until the button is released.  Within the
method 'self.ignore()' it is checked wether the button from eventpress
and eventrelease are the same.

"""
from matplotlib.widgets import RectangleSelector
from pylab import subplot,arange,plot,sin,cos,pi,show
def line_select_callback(event1, event2):
    'event1 and event2 are the press and release events'
    x1, y1 = event1.xdata, event1.ydata
    x2, y2 = event2.xdata, event2.ydata
    print "(%3.2f, %3.2f) --> (%3.2f, %3.2f)"%(x1,y1,x2,y2)
    print " The button you used were: ",event1.button, event2.button


current_ax=subplot(111)                    # make a new plotingrange
N=100000                                   # If N is large one can see improvement
x=10.0*arange(N)/(N-1)                     # by use blitting!

plot(x,sin(.2*pi*x),lw=3,c='b',alpha=.7)   # plot something
plot(x,cos(.2*pi*x),lw=3.5,c='r',alpha=.5)
plot(x,-sin(.2*pi*x),lw=3.5,c='g',alpha=.3)

print "\n      click  -->  release"

# drawtype is 'box' or 'line' or 'none'
LS = RectangleSelector(current_ax, line_select_callback,
                       drawtype='box',useblit=True,
                       minspanx=5,minspany=5,spancoords='pixels')
show()
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.