| 
     
      
      
      From: minakawa <nom...@kc...> - 2008-02-12 02:06:47
       
  
        
          
            Attachments:
            AfterZoom.JPG
          
        
       
     | 
#!/usr/bin/env python
import numpy as npy
import matplotlib.numerix as nx
import matplotlib.numerix.ma as ma
from matplotlib import cm, colors
import matplotlib
matplotlib.use('WXAgg')
from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas
from matplotlib.backends.backend_wx import NavigationToolbar2Wx
from matplotlib.figure import Figure
import wx
class CanvasFrame(wx.Frame):
    def __init__(self):
        wx.Frame.__init__(self,None,-1,
                         'CanvasFrame',size=(550,350))
#        self.SetBackgroundColour(wx.NamedColor("WHITE"))
        self.figure = Figure()
        ax1 = self.figure.add_subplot(121)
        ax2 = self.figure.add_subplot(122)
        x = npy.arange(0, 4.0, 0.05, dtype=float)
        y = npy.arange(0, 5.0, 0.05, dtype=float)
        z = npy.sqrt(x[npy.newaxis,:-1]**2 + y[:-1,npy.newaxis]**2)
        Z = ma.masked_where(z < 1, z)
        X, Y = npy.meshgrid(x,y)
        ax1.pcolor(X,Y,Z)
        ax2.pcolorfast(X,Y,Z)
        ax1.set_title('pcolor')
        ax2.set_title('pcolorfast')  
        self.canvas = FigureCanvas(self, -1, self.figure)
        self.sizer = wx.BoxSizer(wx.VERTICAL)
        self.sizer.Add(self.canvas, 1, wx.LEFT | wx.TOP | wx.GROW)
        self.SetSizer(self.sizer)
        self.Fit()
        self.add_toolbar()  # comment this out for no toolbar
    def add_toolbar(self):
        self.toolbar = NavigationToolbar2Wx(self.canvas)
        self.toolbar.Realize()
        tw, th = self.toolbar.GetSizeTuple()
        fw, fh = self.canvas.GetSizeTuple()
 
        self.toolbar.SetSize(wx.Size(fw, th))
        self.sizer.Add(self.toolbar, 0, wx.LEFT | wx.EXPAND)
        # update the axes menu on the toolbar
        self.toolbar.update()
    def OnPaint(self, event):
        self.canvas.draw()
class App(wx.App):
    def OnInit(self):
        'Create the main window and insert the custom frame'
        frame = CanvasFrame()
        frame.Show(True)
        return True
app = App(0)
app.MainLoop()
 | 
| 
     
      
      
      From: Eric F. <ef...@ha...> - 2008-02-12 07:38:17
       
   | 
This is a longstanding problem with the quadmesh extension code that is
used by pcolorfast when the grid is not rectangular.  It is not likely
to be fixed on the maintenance branch, but it is fixed on the svn trunk,
thanks to work by Michael Drooettboom.
Eric
minakawa wrote:
> Hello List,
>  
> I found a problem that masked  "pcolorfast" does not work properly in 
> zooming,
> It seems that masked area is not refreshed after zooming on "WXAgg".
> I think "pcolorfast" works well on pylab.plot though.
>  
> "pcolormesh" is the same while "pcolor"acts appropriately,   
> Please look at the attached picture and try the sample program.
>  
> My environment is;
>  
>    Windows XP
>    Python 2.4
>    WxPython 2.8
>    matplotlib 0.91.2
>  
> Noriko Minakawa
> 
> ------------------------------------------------------------------------
> 
> 
> ------------------------------------------------------------------------
> 
> ���#!/usr/bin/env python
> 
> import numpy as npy
> import matplotlib.numerix as nx
> 
> import matplotlib.numerix.ma as ma
> from matplotlib import cm, colors
> 
> import matplotlib
> 
> matplotlib.use('WXAgg')
> from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas
> from matplotlib.backends.backend_wx import NavigationToolbar2Wx
> 
> from matplotlib.figure import Figure
> 
> import wx
> 
> class CanvasFrame(wx.Frame):
> 
>     def __init__(self):
>         wx.Frame.__init__(self,None,-1,
>                          'CanvasFrame',size=(550,350))
> 
> #        self.SetBackgroundColour(wx.NamedColor("WHITE"))
> 
>         self.figure = Figure()
>         ax1 = self.figure.add_subplot(121)
>         ax2 = self.figure.add_subplot(122)
> 
>         x = npy.arange(0, 4.0, 0.05, dtype=float)
>         y = npy.arange(0, 5.0, 0.05, dtype=float)
> 
>         z = npy.sqrt(x[npy.newaxis,:-1]**2 + y[:-1,npy.newaxis]**2)
> 
>         Z = ma.masked_where(z < 1, z)
> 
>         X, Y = npy.meshgrid(x,y)
> 
>         ax1.pcolor(X,Y,Z)
>         ax2.pcolorfast(X,Y,Z)
> 
>         ax1.set_title('pcolor')
>         ax2.set_title('pcolorfast')  
> 
>         self.canvas = FigureCanvas(self, -1, self.figure)
> 
>         self.sizer = wx.BoxSizer(wx.VERTICAL)
>         self.sizer.Add(self.canvas, 1, wx.LEFT | wx.TOP | wx.GROW)
>         self.SetSizer(self.sizer)
>         self.Fit()
> 
>         self.add_toolbar()  # comment this out for no toolbar
> 
> 
>     def add_toolbar(self):
>         self.toolbar = NavigationToolbar2Wx(self.canvas)
>         self.toolbar.Realize()
>         tw, th = self.toolbar.GetSizeTuple()
>         fw, fh = self.canvas.GetSizeTuple()
>  
>         self.toolbar.SetSize(wx.Size(fw, th))
>         self.sizer.Add(self.toolbar, 0, wx.LEFT | wx.EXPAND)
> 
>         # update the axes menu on the toolbar
>         self.toolbar.update()
> 
>     def OnPaint(self, event):
>         self.canvas.draw()
> 
> class App(wx.App):
> 
>     def OnInit(self):
>         'Create the main window and insert the custom frame'
>         frame = CanvasFrame()
>         frame.Show(True)
> 
>         return True
> 
> app = App(0)
> app.MainLoop()
> 
 |