SourceForge logo
SourceForge logo
Menu

matplotlib-devel

From: hjc520070 <jia...@16...> - 2007年11月29日 13:34:33
I just want to show a matplotlib.image.AxesImage on a figure. But It can't
work properly. Can somebody help me? The code are following: when I run it
, It just show a white figure. But I Set it cm.Greens .It doesn't work .
Why?
# -*- coding:gb2312 -*- 
import matplotlib
matplotlib.use("WXAgg")
matplotlib.interactive(True)
from matplotlib.backends.backend_wx import FigureCanvasWx
from matplotlib.figure import Figure
from matplotlib.axes import Subplot
from numpy import *
import wx
class ShowPlot():
 def __init__(self,Frame):
 delta = 0.025
 x = arange(-2.0, 2.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((6,6), 70)
 self.canvas = FigureCanvasWx(Frame, -1, self.fig)
 self.axe=self.fig.add_axes([0.1, 0.1, 0.8, 0.8])
 
i=matplotlib.image.AxesImage(self.axe,data=Z,interpolation='bilinear',
origin='lower',cmap=cm.Greens, extent=(-2,2,-2,2))
app = wx.PySimpleApp()
f=wx.Frame(None,size=(600,600))
f.Show(True)
ShowPlot(f)
app.MainLoop()
-- 
View this message in context: http://www.nabble.com/matplotlib.image.AxesImage-can%27t-work.-tf4897267.html#a14025951
Sent from the matplotlib - devel mailing list archive at Nabble.com.
From: John H. <jd...@gm...> - 2007年11月29日 15:21:58
On Nov 29, 2007 7:34 AM, hjc520070 <jia...@16...> wrote:
>
> I just want to show a matplotlib.image.AxesImage on a figure. But It can't
> work properly. Can somebody help me? The code are following: when I run it
> , It just show a white figure. But I Set it cm.Greens .It doesn't work .
AxesImage is not meant to be instantiated directly, but to be created
via ax.imshow, so I suggest you do that. imshow will return and
AxesImage instance to you. But it looks like your problem is you did
not add the image to the axes via ax.images.append.
For future reference, this type of question is probably best directed
to matplotlib-users, since the devel list is for matplotlib
development rather than usage.
Thanks,
JDH
From: hjc520070 <jia...@16...> - 2007年11月30日 13:35:21
Thank u for your help. I did it as your reply. But some questions appear
again . Can you give me some more advice , your help will be appreciated.
Code are as following: You know when I do "self.ax.images.append(self.im)"
in pylab . It do properly , But ,it fail here. Thank you!
# -*- coding:gb2312 -*- 
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 matplotlib.image import NonUniformImage
import numpy as npy
 
#---------------------------------------------------
class DynamicPlot():
 def __init__(self,Frame):
 x = npy.arange(-4, 4, 0.005)
 y = npy.arange(-4, 4, 0.005)
 z = npy.sqrt(x[npy.newaxis,:]**2 + y[:,npy.newaxis]**2)
 
 self.fig = Figure((8,8), 75)
 self.canvas = FigureCanvasWx(Frame, -1, self.fig)
 self.ax=self.fig.add_subplot(111)
 self.im = NonUniformImage(self.ax)
 self.im.set_data(x, y, z)
 self.ax.images.append(self.im)
 self.ax.imshow(self.im)
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/matplotlib.image.AxesImage-can%27t-work.-tf4897267.html#a14057748
Sent from the matplotlib - devel mailing list archive at Nabble.com.
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 によって変換されたページ (->オリジナル) /