Changeset 2475
- Timestamp:
- 02/13/2008 04:35:13 PM (11 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/fipy/viewers/matplotlibViewer/matplotlib2DViewer.py
r2341 r2475 89 89 """ 90 90 MatplotlibViewer.__init__(self, vars=vars, limits=limits, title=title, figaspect=1. / 1.3) 91 91 92 92 self.colorbar = None 93 93 … … 102 102 103 103 polys = [] 104 ## for x, y in zip(xCoords.swapaxes(0,1), yCoords.swapaxes(0,1)): 105 ## if hasattr(x, 'mask'): 106 ## x = x.compressed() 107 ## if hasattr(y, 'mask'): 108 ## y = y.compressed() 109 ## polys.append(x) 110 ## polys.append(y) 111 ## polys.append('b') 112 104 113 for x, y in zip(xCoords.swapaxes(0,1), yCoords.swapaxes(0,1)): 105 114 if hasattr(x, 'mask'): … … 107 116 if hasattr(y, 'mask'): 108 117 y = y.compressed() 109 polys.append(x) 110 polys.append(y) 111 polys.append('b') 118 polys.append(zip(x,y)) 112 119 113 120 import pylab … … 115 122 116 123 fig = pylab.figure(self.id) 124 117 125 ax = fig.get_axes()[0] 118 self.polygons = ax.fill(linewidth=0., *polys) 126 127 from matplotlib.collections import PolyCollection 128 self.collection = PolyCollection(polys) 129 self.collection.set_linewidth(0) 130 ax.add_patch(self.collection) 131 132 if self._getLimit('xmin') is None: 133 xmin = min(numerix.array(self.collection._verts)[:,:,0].flat) 134 else: 135 xmin = self._getLimit('xmin') 136 137 if self._getLimit('xmax') is None: 138 xmax = max(numerix.array(self.collection._verts)[:,:,0].flat) 139 else: 140 xmax = self._getLimit('xmax') 141 142 if self._getLimit('ymin') is None: 143 ymin = min(numerix.array(self.collection._verts)[:,:,1].flat) 144 else: 145 ymin = self._getLimit('ymin') 146 147 if self._getLimit('ymax') is None: 148 ymax = max(numerix.array(self.collection._verts)[:,:,1].flat) 149 else: 150 ymax = self._getLimit('ymax') 151 152 pylab.axis((xmin, xmax, ymin, ymax)) 153 154 ## self.polygons = ax.fill(linewidth=0., *polys) 119 155 120 156 cbax, kw = matplotlib.colorbar.make_axes(ax, orientation='vertical') … … 167 203 import pylab 168 204 import matplotlib 169 170 for poly, value in zip(self.polygons, Z): 205 206 faceColors = [] 207 208 for value in Z: 171 209 if diff == 0: 172 210 rgba = pylab.cm.jet(0.5) … … 174 212 rgba = pylab.cm.jet((value - zmin) / diff) 175 213 176 poly.set_facecolor(rgba) 214 faceColors.append(rgba) 215 216 self.collection.set_facecolors(faceColors) 217 ## self.collection.set_edgecolors(faceColors) 218 219 ## for poly, value in zip(self.polygons, Z): 220 ## if diff == 0: 221 ## rgba = pylab.cm.jet(0.5) 222 ## else: 223 ## rgba = pylab.cm.jet((value - zmin) / diff) 224 225 ## poly.set_facecolor(rgba) 177 226 178 227 self.cb.norm = matplotlib.colors.normalize(vmin=zmin, vmax=zmax) 179 228 self.cb.draw_all() 180 229 181 pylab.xlim(xmin=self._getLimit('xmin'),182 xmax=self._getLimit('xmax'))183 184 pylab.ylim(ymin=self._getLimit('ymin'),185 ymax=self._getLimit('ymax'))230 ## pylab.xlim(xmin=self._getLimit('xmin'), 231 ## xmax=self._getLimit('xmax')) 232 233 ## pylab.ylim(ymin=self._getLimit('ymin'), 234 ## ymax=self._getLimit('ymax')) 186 235 187 236 def plotMesh(self, filename = None):
FiPy: A Finite Volume PDE Solver Using Python