How to show matplotlib.image ?

The following run well . But I just want to make the image, with the x and y
as axis and z as the image value ,show on the figure. In the pylab , we can
just give a command "imshow" ,But here , I fail to do it , I have try
ax.imshow() again and again ,but fail. Can sb give me some advice . Thank
you .

import matplotlib
matplotlib.use("WXAgg")
matplotlib.interactive(True)
from matplotlib.backends.backend_wx import FigureCanvasWx
from matplotlib.figure import Figure
from matplotlib.axes import *
from numpy import *
import wx
from pylab import *

···

#---------------------------------------------------

class DynamicPlot():
    def __init__(self,Frame):
        delta = 0.025
        x = arange(-3.0, 3.0, delta)
        y = arange(-2.0, 2.0, delta)
        X, Y = meshgrid(x, y)
        Z1 = bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0)
        Z2 = bivariate_normal(X, Y, 1.5, 0.5, 1, 1)
        Z = 10.0 * (Z2 - Z1)
        levels = arange(-1.2, 1.6, 0.2)
        self.fig = Figure((8,8), 75)
        self.canvas = FigureCanvasWx(Frame, -1, self.fig)
        ax=self.fig.add_axes([0.1,0.1,0.8,0.8])
       
ax.contour(X,Y,Z,levels,origin='lower',linewidths=2,extent=(-3,3,-2,2))
app = wx.PySimpleApp()
f=wx.Frame(None,size=(600,600))
f.Show(True)
DynamicPlot(f)
app.MainLoop()

View this message in context: http://www.nabble.com/How-to-show-matplotlib.image---tf4930297.html#a14111799
Sent from the matplotlib - users mailing list archive at Nabble.com.

You cannot import pylab and use the FigureCanvasWx at the same time.
Please follow the lead of examples/embedding_in_wx*.py if you want to
use matplotlib in a wxpython GUI. Using pylab at the same time as the
API is undefined and unsupported.

JDH

···

On Dec 1, 2007 7:47 PM, hjc520070 <jiacong_huang@...1221...> wrote:

The following run well . But I just want to make the image, with the x and y
as axis and z as the image value ,show on the figure. In the pylab , we can
just give a command "imshow" ,But here , I fail to do it , I have try
ax.imshow() again and again ,but fail. Can sb give me some advice . Thank
you .

John Hunter wrote:

You cannot import pylab and use the FigureCanvasWx at the same time.
Please follow the lead of examples/embedding_in_wx*.py if you want to
use matplotlib in a wxpython GUI.

or use wxmpl:

http://agni.phys.iit.edu/~kmcivor/wxmpl/

By the way, couldn't that be distributed with Matplotlib? Maybe in toolkits, if not the main distro.

-Chris

···

--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@...259...

As as wxmpl user I say that is a great great idea!

Christopher Barker wrote:

···

John Hunter wrote:
  

You cannot import pylab and use the FigureCanvasWx at the same time.
Please follow the lead of examples/embedding_in_wx*.py if you want to
use matplotlib in a wxpython GUI.
    
or use wxmpl:

http://agni.phys.iit.edu/~kmcivor/wxmpl/

By the way, couldn't that be distributed with Matplotlib? Maybe in toolkits, if not the main distro.

-Chris

I'd be all for having wxmpl distributed as part of the matplotlib toolkits. I had originally hoped to merge it into the main distribution after unifying the event handling so that matplotlib events worked robustly, but I don't see myself finding the time to work on it any time soon.

Ken

···

On Dec 5, 2007, at 11:58 AM, Christopher Barker wrote:

or use wxmpl:

http://agni.phys.iit.edu/~kmcivor/wxmpl/

By the way, couldn't that be distributed with Matplotlib? Maybe in
toolkits, if not the main distro.