Thanks for your helpful response.
I used wx, I’m mystified to as how to make the scroll bars bound the subplot. not the frame. The gtk example you pointed me to creates horizontal and vertical scrollbars around the whole frame, not within the subplot. i.e., if the subplot is very large , scrollbars bounding the subplot would be great…
Below is a sample of the code I attempted, let me know if I would need to make any corrections to it :
import wx
from matplotlib.axes import Subplot
from matplotlib.figure import Figure
from matplotlib.numerix import arange, sin, pi
class ScrollbarFrame(wx.Frame):
def init(self):
wx.Frame.init(self, None, -1, ‘Scrollbar example’,size=(300,200))
print “self”
print self
self.scroll = wx.ScrolledWindow(self, -1)
print "self.scroll"
print self.scroll
self.figure = Figure(figsize=(5,4), dpi=100)
self.axes = self.figure.add_subplot(111)
t = arange(0.0,3.0,0.01)
s = sin(2*pi*t)
self.axes.plot(t,s)
self.canvas = FigureCanvas(self, -1, self.figure)
self.scroll.SetScrollbars(5,5,600,400)
#self.scroll.FitInside()
if name == ‘main’:
app = wx.PySimpleApp()
frame = ScrollbarFrame()
frame.Show()
app.MainLoop()
Thanks,
iyer
···
John Hunter <jdh2358@…287…> wrote:
On 3/19/07, lazardo wrote:
I’m curious … how can we include a scrollbar with a subplot, instead of the
back and front arrows to view the subplot. Googling
matplotlib+scrollbar+subplot brings up a very few results, so I guess it
hasn’t been attempted before.The exact details depend on your GUI – there is no generic support
for this in pylab but since you can embed matplotlib in the GUI widget
of your choice it is certainly possible. Below is a gtk example
embedding_in_gtk3.py from the matplotlib examples directoryimport gtk
from matplotlib.axes import Subplot
from matplotlib.figure import Figure
from matplotlib.numerix import arange, sin, piuncomment to select /GTK/GTKAgg/GTKCairo
#from matplotlib.backends.backend_gtk import FigureCanvasGTK as FigureCanvas
from matplotlib.backends.backend_gtkagg import FigureCanvasGTKAgg as
FigureCanvas
#from matplotlib.backends.backend_gtkcairo import FigureCanvasGTKCairo
as FigureCanvaswin = gtk.Window()
win.connect(“destroy”, lambda x: gtk.main_quit())
win.set_default_size(400,300)
win.set_title(“Embedding in GTK”)f = Figure(figsize=(5,4), dpi=100)
a = f.add_subplot(111)
t = arange(0.0,3.0,0.01)
s = sin(2pit)
a.plot(t,s)sw = gtk.ScrolledWindow()
win.add (sw)A scrolled window border goes outside the scrollbars and viewport
sw.set_border_width (10)
policy: ALWAYS, AUTOMATIC, NEVER
sw.set_policy (hscrollbar_policy=gtk.POLICY_AUTOMATIC,
vscrollbar_policy=gtk.POLICY_ALWAYS)canvas = FigureCanvas(f) # a gtk.DrawingArea
canvas.set_size_request(800,600)
sw.add_with_viewport (canvas)win.show_all()
gtk.main()
Don’t pick lemons.
See all the new 2007 cars at Yahoo! Autos.