Skip to content

Instantly share code, notes, and snippets.

@taldcroft
Created May 21, 2012 01:47
Show Gist options
  • Save taldcroft/2760243 to your computer and use it in GitHub Desktop.
Save taldcroft/2760243 to your computer and use it in GitHub Desktop.
embed gtk in matplotlib example
import gtk
import numpy as np
from matplotlib.figure import Figure
from matplotlib.backends.backend_gtkagg import FigureCanvasGTKAgg
win = gtk.Window()
win.connect("destroy", lambda x: gtk.main_quit())
win.set_default_size(400,300)
fig = Figure(figsize=(5,4), dpi=100)
ax = fig.add_subplot(1, 1, 1)
# Do something (make a plot)
canvas = FigureCanvasGTKAgg(fig) # a gtk.DrawingArea
win.add(canvas)
win.show_all()
gtk.main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment