コード例 #1
0
ファイル: mapaxes.py プロジェクト: yanxinorg/MeteoInfoLab
 def data2pixel(self, x, y, z=None):
     '''
     Transform data coordinate to screen coordinate
     
     :param x: (*float*) X coordinate.
     :param y: (*float*) Y coordinate.
     :param z: (*float*) Z coordinate - only used for 3-D axes.
     '''
     if not self.axes.isLonLatMap():
         x, y = minum.project(x, y, toproj=self.proj)  
         
     rect = self.axes.getPositionArea()
     r = self.axes.projToScreen(x, y, rect)
     sx = r[0] + rect.getX()
     sy = r[1] + rect.getY()
     sy = self.figure.get_size()[1] - sy
     return sx, sy
コード例 #2
0
ファイル: mapaxes.py プロジェクト: yanxinorg/MeteoInfoLab
    def pcolor(self, *args, **kwargs):
        """
        Create a pseudocolor plot of a 2-D array in a MapAxes.
        
        :param x: (*array_like*) Optional. X coordinate array.
        :param y: (*array_like*) Optional. Y coordinate array.
        :param z: (*array_like*) 2-D z value array.
        :param levs: (*array_like*) Optional. A list of floating point numbers indicating the level curves 
            to draw, in increasing order.
        :param cmap: (*string*) Color map string.
        :param colors: (*list*) If None (default), the colormap specified by cmap will be used. If a 
            string, like ‘r’ or ‘red’, all levels will be plotted in this color. If a tuple of matplotlib 
            color args (string, float, rgb, etc), different levels will be plotted in different colors in 
            the order specified.
        :param fill_value: (*float*) Fill_value. Default is ``-9999.0``.
        :param proj: (*ProjectionInfo*) Map projection of the data. Default is None.
        :param isadd: (*boolean*) Add layer or not. Default is ``True``.
        :param zorder: (*int*) Z-order of created layer for display.
        :param select: (*boolean*) Set the return layer as selected layer or not.
        
        :returns: (*VectoryLayer*) Polygon VectoryLayer created from array data.
        """    
        proj = kwargs.pop('proj', None)            
        n = len(args) 
        if n <= 2:
            a = args[0]
            y = a.dimvalue(0)
            x = a.dimvalue(1)
            args = args[1:]
        else:
            x = args[0]
            y = args[1]
            a = args[2]
            args = args[3:]
            
        if a.ndim == 2 and x.ndim == 1:            
            x, y = minum.meshgrid(x, y)  
            
        ls = plotutil.getlegendscheme(args, a.min(), a.max(), **kwargs)   
        ls = ls.convertTo(ShapeTypes.Polygon)
        plotutil.setlegendscheme(ls, **kwargs)
            
        if proj is None or proj.isLonLat():
            lonlim = 90
        else:
            lonlim = 0
            x, y = minum.project(x, y, toproj=proj)
        layer = ArrayUtil.meshLayer(x.asarray(), y.asarray(), a.asarray(), ls, lonlim)
        #layer = ArrayUtil.meshLayer(x.asarray(), y.asarray(), a.asarray(), ls)
        if not proj is None:
            layer.setProjInfo(proj)
            
        # Add layer
        isadd = kwargs.pop('isadd', True)
        if isadd:
            zorder = kwargs.pop('zorder', None)
            select = kwargs.pop('select', True)
            if zorder is None:
                zorder = 0
            self.add_layer(layer, zorder, select)
            self.axes.setDrawExtent(layer.getExtent().clone())
            self.axes.setExtent(layer.getExtent().clone())

        return MILayer(layer)