File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import matplotlib
2+ matplotlib .use ('GTK' )
3+
4+ from matplotlib .backends .backend_gtk import Figure , NavigationToolbar
5+
6+ from matplotlib .axes import Subplot
7+ import Numeric as numpy
8+ import gtk
9+
10+ win = gtk .Window ()
11+ win .set_name ("Embedding in GTK" )
12+ win .connect ("destroy" , gtk .mainquit )
13+ win .set_border_width (5 )
14+
15+ vbox = gtk .VBox (spacing = 3 )
16+ win .add (vbox )
17+ vbox .show ()
18+
19+ f = Figure (figsize = (5 ,4 ), dpi = 100 )
20+ a = Subplot (f , 111 )
21+ t = numpy .arange (0.0 ,3.0 ,0.01 )
22+ s = numpy .sin (2 * numpy .pi * t )
23+
24+ a .plot (t ,s )
25+ f .add_axis (a )
26+ f .show ()
27+ vbox .pack_start (f )
28+
29+ toolbar = NavigationToolbar (f , win )
30+ toolbar .show ()
31+ vbox .pack_start (toolbar , gtk .FALSE , gtk .FALSE )
32+
33+ button = gtk .Button ('Quit' )
34+ button .connect ('clicked' , lambda b : gtk .mainquit ())
35+ button .show ()
36+ vbox .pack_start (button )
37+
38+ win .show ()
39+ gtk .mainloop ()
You can’t perform that action at this time.
0 commit comments