SourceForge logo
SourceForge logo
Menu

matplotlib-users

From: Jon F. <jo...@dr...> - 2006年02月27日 16:48:03
I'm trying to embed functionality similar to the pylab.imshow() feature
in a gtk application, but my bony head can't find an example program where someone 
does this explicitly, and hunting in the pylab interface has been rather
frustrating. 
I'm using the the more typical x-y plots in gtk apps aleady (thank you
example writers), but the ability to show an colormapped 2d image with a
color bar would be really great.
Any takers?
-- Jon
-- 
.*. Dr. Jon R. Fox
..* http://www.drfox.com
*** jo...@dr...
From: Jon F. <jo...@dr...> - 2006年02月27日 17:24:06
I thought for a bit longer and found something that works just right:
#!/usr/bin/env python
import pygtk
pygtk.require('2.0')
import gtk
import matplotlib
matplotlib.use('GTK')
from matplotlib.figure import Figure
from matplotlib.backends.backend_gtk import FigureCanvasGTK, NavigationToolbar
from Numeric import *
def close_app(widget, data=None):
 """ A call back if the close window control is clicked."""
 print "delete_event being handled" 
 gtk.main_quit() # gracefully end the application.
if __name__ == "__main__": 
 main_window = gtk.Window(gtk.WINDOW_TOPLEVEL)
 # Connect the delete_event signal to a function to close the application.
 main_window.connect( "delete_event", close_app)
 main_window.show() 
 figure = Figure(figsize=(6,4), dpi=72) 
 axes = figure.add_subplot(111)
 # This calls the imshow routine and builds an Axes instance for us.
 axes.imshow( array([[2,4,5,5],[5,6,7,8],[7,6,5,7]]))
 main_window.set_border_width(10)
 
 figure_canvas = FigureCanvasGTK(figure)
 nav_tool = NavigationToolbar(figure_canvas,main_window)
 nav_tool.show()
 figure_canvas.show()
 
 vbox = gtk.VBox()
 vbox.show()
 vbox.pack_start(figure_canvas)
 vbox.pack_start(nav_tool, False, False)
 
 main_window.add(vbox) 
 gtk.main() 
 
On Mon, Feb 27, 2006 at 11:47:57AM -0500, Jon Fox wrote:
> I'm trying to embed functionality similar to the pylab.imshow() feature
> in a gtk application, but my bony head can't find an example program where someone 
> does this explicitly, and hunting in the pylab interface has been rather
> frustrating. 
> 
> I'm using the the more typical x-y plots in gtk apps aleady (thank you
> example writers), but the ability to show an colormapped 2d image with a
> color bar would be really great.
> 
> Any takers?
> 
> -- Jon
> 
> -- 
> .*. Dr. Jon R. Fox
> ..* http://www.drfox.com
> *** jo...@dr...
> 
> 
> -------------------------------------------------------
> This SF.Net email is sponsored by xPML, a groundbreaking scripting language
> that extends applications into web and mobile media. Attend the live webcast
> and join the prime developer group breaking into this new coding territory!
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
-- 
.*. Dr. Jon R. Fox
..* http://www.drfox.com
*** jo...@dr...
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /