コード例 #1
0
ファイル: quiver.py プロジェクト: jtomase/matplotlib
 def _make_verts(self, U, V):
     uv = ma.asarray(U + V * 1j)
     a = ma.absolute(uv)
     if self.scale is None:
         sn = max(10, math.sqrt(self.N))
         scale = 1.8 * a.mean() * sn / self.span  # crude auto-scaling
         self.scale = scale
     length = a / (self.scale * self.width)
     X, Y = self._h_arrows(length)
     # There seems to be a ma bug such that indexing
     # a masked array with one element converts it to
     # an ndarray.
     theta = npy.angle(ma.asarray(uv[..., npy.newaxis]).filled(0))
     xy = (X + Y * 1j) * npy.exp(1j * theta) * self.width
     xy = xy[:, :, npy.newaxis]
     XY = ma.concatenate((xy.real, xy.imag), axis=2)
     return XY
コード例 #2
0
ファイル: quiver.py プロジェクト: gkliska/razvoj
 def _make_verts(self, U, V):
     uv = ma.asarray(U+V*1j)
     a = ma.absolute(uv)
     if self.scale is None:
         sn = max(10, math.sqrt(self.N))
         scale = 1.8 * a.mean() * sn / self.span # crude auto-scaling
         self.scale = scale
     length = a/(self.scale*self.width)
     X, Y = self._h_arrows(length)
     # There seems to be a ma bug such that indexing
     # a masked array with one element converts it to
     # an ndarray.
     theta = npy.angle(ma.asarray(uv[..., npy.newaxis]).filled(0))
     xy = (X+Y*1j) * npy.exp(1j*theta)*self.width
     xy = xy[:,:,npy.newaxis]
     XY = ma.concatenate((xy.real, xy.imag), axis=2)
     return XY
コード例 #3
0
    def recache(self):
        #if self.axes is None: print 'recache no axes'
        #else: print 'recache units', self.axes.xaxis.units, self.axes.yaxis.units
        if ma.isMaskedArray(self._xorig) or ma.isMaskedArray(self._yorig):
            x = ma.asarray(self.convert_xunits(self._xorig), float)
            y = ma.asarray(self.convert_yunits(self._yorig), float)
            x = ma.ravel(x)
            y = ma.ravel(y)
        else:
            x = npy.asarray(self.convert_xunits(self._xorig), float)
            y = npy.asarray(self.convert_yunits(self._yorig), float)
            x = npy.ravel(x)
            y = npy.ravel(y)

        if len(x)==1 and len(y)>1:
            x = x * npy.ones(y.shape, float)
        if len(y)==1 and len(x)>1:
            y = y * npy.ones(x.shape, float)

        if len(x) != len(y):
            raise RuntimeError('xdata and ydata must be the same length')

        x = x.reshape((len(x), 1))
        y = y.reshape((len(y), 1))

        if ma.isMaskedArray(x) or ma.isMaskedArray(y):
            self._xy = ma.concatenate((x, y), 1)
        else:
            self._xy = npy.concatenate((x, y), 1)
	self._x = self._xy[:, 0] # just a view
	self._y = self._xy[:, 1] # just a view

        # Masked arrays are now handled by the Path class itself
        self._path = Path(self._xy)
        self._transformed_path = TransformedPath(self._path, self.get_transform())

        self._invalid = False