コード例 #1
0
ファイル: axes3d.py プロジェクト: meteoinfo/MeteoInfoLab
 def fill_between(self, x, y1, y2=0, where=None, **kwargs):
     """
     Make filled polygons between two curves (y1 and y2) where ``where==True``.
     
     :param x: (*array_like*) An N-length array of the x data.
     :param y1: (*array_like*) An N-length array (or scalar) of the y data.
     :param y2: (*array_like*) An N-length array (or scalar) of the y data.
     :param where: (*array_like*) If None, default to fill between everywhere. If not None, it is an 
         N-length boolean array and the fill will only happen over the regions where ``where==True``.
     """
     #Get dataset
     global gca   
     
     #Add data series
     label = kwargs.pop('label', 'S_0')
     dn = len(x)
     xdata = plotutil.getplotdata(x)
     if isinstance(y1, (int, long, float)):
         yy = []
         for i in range(dn):
             yy.append(y1)
         y1 = minum.array(yy).array
     else:
         y1 = plotutil.getplotdata(y1)
     if isinstance(y2, (int, long, float)):
         yy = []
         for i in range(dn):
             yy.append(y2)
         y2 = minum.array(yy).array
     else:
         y2 = plotutil.getplotdata(y2)
     if not where is None:
         if isinstance(where, (tuple, list)):
             where = minum.array(where)
         where = where.asarray()
     
     #Set plot data styles
     if not 'fill' in kwargs:
         kwargs['fill'] = True
     if not 'edge' in kwargs:
         kwargs['edge'] = False
     pb, isunique = plotutil.getlegendbreak('polygon', **kwargs)
     pb.setCaption(label)
     
     #Create graphics
     offset = kwargs.pop('offset', 0)
     zdir = kwargs.pop('zdir', 'z')
     if zdir == 'xy':
         y = kwargs.pop('y', x)
         ydata = plotutil.getplotdata(y)
         graphics = GraphicFactory.createFillBetweenPolygons(xdata, ydata, y1, y2, where, pb, \
             offset, zdir) 
     else:
         graphics = GraphicFactory.createFillBetweenPolygons(xdata, y1, y2, where, pb, \
             offset, zdir) 
         
     visible = kwargs.pop('visible', True)
     if visible:
         self.add_graphic(graphics)
     return graphics
コード例 #2
0
ファイル: axes3d.py プロジェクト: meteoinfo/MeteoInfoLab
    def plot_wireframe(self, *args, **kwargs):
        '''
        creates a three-dimensional wireframe plot
        
        :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 cmap: (*string*) Color map string.
        :param xyaxis: (*boolean*) Draw x and y axis or not.
        :param zaxis: (*boolean*) Draw z axis or not.
        :param grid: (*boolean*) Draw grid or not.
        :param boxed: (*boolean*) Draw boxed or not.
        :param mesh: (*boolean*) Draw mesh line or not.
        
        :returns: Legend
        '''        
        if len(args) == 1:
            x = args[0].dimvalue(1)
            y = args[0].dimvalue(0)
            x, y = minum.meshgrid(x, y)
            z = args[0]    
            args = args[1:]
        else:
            x = args[0]
            y = args[1]
            z = args[2]
            args = args[3:]
 
        line = plotutil.getlegendbreak('line', **kwargs)[0]
        graphics = GraphicFactory.createWireframe(x.asarray(), y.asarray(), z.asarray(), line)
        visible = kwargs.pop('visible', True)
        if visible:
            self.add_graphic(graphics)
        return graphics
コード例 #3
0
ファイル: axes3d.py プロジェクト: meteoinfo/MeteoInfoLab
    def plot_layer(self, layer, **kwargs):
        '''
        Plot a layer in 3D axes.
        
        :param layer: (*MILayer*) The layer to be plotted.
        
        :returns: Graphics.
        '''
        ls = kwargs.pop('symbolspec', None)
        offset = kwargs.pop('offset', 0)
        xshift = kwargs.pop('xshift', 0)
        layer = layer.layer
        if layer.getLayerType() == LayerTypes.VectorLayer:            
            if ls is None:
                ls = layer.getLegendScheme()
                if len(kwargs) > 0 and layer.getLegendScheme().getBreakNum() == 1:
                    lb = layer.getLegendScheme().getLegendBreaks().get(0)
                    btype = lb.getBreakType()
                    geometry = 'point'
                    if btype == BreakTypes.PolylineBreak:
                        geometry = 'line'
                    elif btype == BreakTypes.PolygonBreak:
                        geometry = 'polygon'
                    lb, isunique = plotutil.getlegendbreak(geometry, **kwargs)
                    ls.getLegendBreaks().set(0, lb)

            plotutil.setlegendscheme(ls, **kwargs)
            layer.setLegendScheme(ls)                    
            graphics = GraphicFactory.createGraphicsFromLayer(layer, offset, xshift)
        else:
            interpolation = kwargs.pop('interpolation', None)
            graphics = GraphicFactory.createImage(layer, offset, xshift, interpolation)
        
        visible = kwargs.pop('visible', True)
        if visible:
            self.add_graphic(graphics)
        return graphics
コード例 #4
0
ファイル: figure.py プロジェクト: meteoinfo/MeteoInfoLab
    def __set_axesm(self, ax, **kwargs):  
        """
        Create an map axes.
        
        :param bgcolor: (*Color*) Optional, axes background color.
        :param axis: (*boolean*) Optional, set all axis visible or not. Default is ``True`` .
        :param bottomaxis: (*boolean*) Optional, set bottom axis visible or not. Default is ``True`` .
        :param leftaxis: (*boolean*) Optional, set left axis visible or not. Default is ``True`` .
        :param topaxis: (*boolean*) Optional, set top axis visible or not. Default is ``True`` .
        :param rightaxis: (*boolean*) Optional, set right axis visible or not. Default is ``True`` .
        :param xyscale: (*int*) Optional, set scale of x and y axis, default is 1. It is only
            valid in longlat projection.
        :param gridlabel: (*boolean*) Optional, set axis tick labels visible or not. Default is ``True`` .
        :param gridlabelloc: (*string*) Optional, Set grid label locations 
			[left_bottom | left_up | right_bottom | right_up | all]. Default is ``left_bottom'.
		:param gridline: (*boolean*) Optional, set grid line visible or not. Default is ``False`` .
        :param griddx: (*float*) Optional, set x grid line interval. Default is 10 degree.
        :param griddy: (*float*) Optional, set y grid line interval. Default is 10 degree.
        :param frameon: (*boolean*) Optional, set frame visible or not. Default is ``False`` for lon/lat
            projection, ortherwise is ``True``.
        :param tickfontname: (*string*) Optional, set axis tick labels font name. Default is ``Arial`` .
        :param tickfontsize: (*int*) Optional, set axis tick labels font size. Default is 14.
        :param tickbold: (*boolean*) Optional, set axis tick labels font bold or not. Default is ``False`` .
        :param boundaryprop: (*dict*) boundary property.
        
        :returns: The map axes.
        """       
        aspect = kwargs.pop('aspect', 'equal')
        if aspect == 'equal':
            ax.axes.setAutoAspect(False)
        elif aspect == 'auto':
            ax.axes.setAutoAspect(True)
        else:
            if isinstance(aspect, (int, float)):
                ax.axes.setAspect(aspect)
                ax.axes.setAutoAspect(False)
        axis = kwargs.pop('axis', True)
        if axis:
            bottomaxis = kwargs.pop('bottomaxis', True)
            leftaxis = kwargs.pop('leftaxis', True)
            topaxis = kwargs.pop('topaxis', True)
            rightaxis = kwargs.pop('rightaxis', True)
        else:
            bottomaxis = False
            leftaxis = False
            topaxis = False
            rightaxis = False            
        gridlabel = kwargs.pop('gridlabel', True)
        gridlabelloc = kwargs.pop('gridlabelloc', 'left_bottom')
        gridline = kwargs.pop('gridline', False)
        griddx = kwargs.pop('griddx', 10)
        griddy = kwargs.pop('griddy', 10)
        if ax.axes.getProjInfo().isLonLat():
            frameon = kwargs.pop('frameon', False)
        else:
            frameon = kwargs.pop('frameon', True)
        axison = kwargs.pop('axison', None)
        bgcobj = kwargs.pop('bgcolor', None)
        xyscale = kwargs.pop('xyscale', 1)     
        tickfontname = kwargs.pop('tickfontname', 'Arial')
        tickfontsize = kwargs.pop('tickfontsize', 14)
        tickbold = kwargs.pop('tickbold', False)
        if tickbold:
            font = Font(tickfontname, Font.BOLD, tickfontsize)
        else:
            font = Font(tickfontname, Font.PLAIN, tickfontsize)
            
        mapview = ax.axes.getMapView()
        mapview.setXYScaleFactor(xyscale)
        ax.axes.setAspect(xyscale)
        ax.axes.setAxisLabelFont(font)
        if not axison is None:
            ax.axes.setAxisOn(axison)
        else:
            if bottomaxis == False:
                ax.axes.getAxis(Location.BOTTOM).setVisible(False)
            if leftaxis == False:
                ax.axes.getAxis(Location.LEFT).setVisible(False)
            if topaxis == False:
                ax.axes.getAxis(Location.TOP).setVisible(False)
            if rightaxis == False:
                ax.axes.getAxis(Location.RIGHT).setVisible(False)
        mapframe = ax.axes.getMapFrame()
        mapframe.setGridFont(font)
        mapframe.setDrawGridLabel(gridlabel)
        mapframe.setDrawGridTickLine(gridlabel)
        mapframe.setGridLabelPosition(gridlabelloc)
        mapframe.setDrawGridLine(gridline)
        mapframe.setGridXDelt(griddx)
        mapframe.setGridYDelt(griddy)
        ax.axes.setDrawNeatLine(frameon)
        bgcolor = plotutil.getcolor(bgcobj)
        ax.axes.setBackground(bgcolor)
        boundaryprop = kwargs.pop('boundaryprop', None)
        if not boundaryprop is None:
            boundaryprop = plotutil.getlegendbreak('polygon', **boundaryprop)[0]
            ax.axes.setBoundaryProp(boundaryprop)
     
        return ax
コード例 #5
0
ファイル: axes3d.py プロジェクト: meteoinfo/MeteoInfoLab
 def stem(self, x, y, z, s=8, c='b', marker='o', alpha=None, linewidth=None, 
             verts=None, **kwargs):
     """
     Make a 3D scatter plot of x, y and z, where x, y and z are sequence like objects of the same lengths.
     
     :param x: (*array_like*) Input x data.
     :param y: (*array_like*) Input y data.
     :param z: (*array_like*) Input z data.
     :param s: (*int*) Size of points.
     :param c: (*Color*) Color of the points. Or z vlaues.
     :param alpha: (*int*) The alpha blending value, between 0 (transparent) and 1 (opaque).
     :param marker: (*string*) Marker of the points.
     :param label: (*string*) Label of the points series.
     :param levs: (*array_like*) Optional. A list of floating point numbers indicating the level 
         points to draw, in increasing order.
     
     :returns: Points legend break.
     """        
     #Add data series
     label = kwargs.pop('label', 'S_0')
     xdata = plotutil.getplotdata(x)
     ydata = plotutil.getplotdata(y)
     zdata = plotutil.getplotdata(z)
     
     #Set plot data styles
     pb, isunique = plotutil.getlegendbreak('point', **kwargs)
     pb.setCaption(label)
     pstyle = plotutil.getpointstyle(marker)    
     pb.setStyle(pstyle)
     bottom = kwargs.pop('bottom', 0)   
     samestemcolor = kwargs.pop('samestemcolor', False)
     isvalue = False
     if len(c) > 1:
         if isinstance(c, (MIArray, DimArray)):
             isvalue = True
         elif isinstance(c[0], (int, long, float)):
             isvalue = True            
     if isvalue:
         ls = kwargs.pop('symbolspec', None)
         if ls is None:        
             if isinstance(c, (list, tuple)):
                 c = minum.array(c)
             levels = kwargs.pop('levs', None)
             if levels is None:
                 levels = kwargs.pop('levels', None)
             if levels is None:
                 cnum = kwargs.pop('cnum', None)
                 if cnum is None:
                     ls = plotutil.getlegendscheme([], c.min(), c.max(), **kwargs)
                 else:
                     ls = plotutil.getlegendscheme([cnum], c.min(), c.max(), **kwargs)
             else:
                 ls = plotutil.getlegendscheme([levels], c.min(), c.max(), **kwargs)
             ls = plotutil.setlegendscheme_point(ls, **kwargs)
             if isinstance(s, int):
                 for lb in ls.getLegendBreaks():
                     lb.setSize(s)
             else:
                 n = len(s)
                 for i in range(0, n):
                     ls.getLegendBreaks()[i].setSize(s[i])
         linefmt = kwargs.pop('linefmt', None)
         if linefmt is None:
             linefmt = PolylineBreak()
             linefmt.setColor(Color.black)
         else:
             linefmt = plotutil.getlegendbreak('line', **linefmt)[0]
         #Create graphics
         graphics = GraphicFactory.createStems3D(xdata, ydata, zdata, c.asarray(), \
             ls, linefmt, bottom, samestemcolor)
     else:
         colors = plotutil.getcolors(c, alpha)   
         pbs = []
         if isinstance(s, int):   
             pb.setSize(s)
             if len(colors) == 1:
                 pb.setColor(colors[0])
                 pb.setOutlineColor(colors[0])
                 pbs.append(pb)
             else:
                 n = len(colors)
                 for i in range(0, n):
                     npb = pb.clone()
                     npb.setColor(colors[i])
                     npb.setOutlineColor(colors[i])
                     pbs.append(npb)
         else:
             n = len(s)
             if len(colors) == 1:
                 pb.setColor(colors[0])
                 pb.setOutlineColor(colors[0])
                 for i in range(0, n):
                     npb = pb.clone()
                     npb.setSize(s[i])
                     pbs.append(npb)
             else:
                 for i in range(0, n):
                     npb = pb.clone()
                     npb.setSize(s[i])
                     npb.setColor(colors[i])
                     npb.setOutlineColor(colors[i])
                     pbs.append(npb)
         linefmt = kwargs.pop('linefmt', None)
         if linefmt is None:
             linefmt = PolylineBreak()
             linefmt.setColor(colors[0])
         else:
             linefmt = plotutil.getlegendbreak('line', **linefmt)[0]
         #Create graphics
         graphics = GraphicFactory.createStems3D(xdata, ydata, zdata, pbs, linefmt, \
             bottom, samestemcolor)
     
     visible = kwargs.pop('visible', True)
     if visible:
         self.add_graphic(graphics[0])
         self.add_graphic(graphics[1])
     return graphics[0], graphics[1]
コード例 #6
0
ファイル: axes3d.py プロジェクト: meteoinfo/MeteoInfoLab
    def plot(self, x, y, z, *args, **kwargs):
        """
        Plot 3D lines and/or markers to the axes. *args* is a variable length argument, allowing
        for multiple *x, y* pairs with an optional format string.
        
        :param x: (*array_like*) Input x data.
        :param y: (*array_like*) Input y data.
        :param z: (*array_like*) Input z data.
        :param style: (*string*) Line style for plot.
        
        :returns: Legend breaks of the lines.
        
        The following format string characters are accepted to control the line style or marker:
        
          =========  ===========
          Character  Description
          =========  ===========
          '-'         solid line style
          '--'        dashed line style
          '-.'        dash-dot line style
          ':'         dotted line style
          '.'         point marker
          ','         pixel marker
          'o'         circle marker
          'v'         triangle_down marker
          '^'         triangle_up marker
          '<'         triangle_left marker
          '>'         triangle_right marker
          's'         square marker
          'p'         pentagon marker
          '*'         star marker
          'x'         x marker
          'D'         diamond marker
          =========  ===========
          
        The following color abbreviations are supported:
          
          =========  =====
          Character  Color  
          =========  =====
          'b'        blue
          'g'        green
          'r'        red
          'c'        cyan
          'm'        magenta
          'y'        yellow
          'k'        black
          =========  =====
        """      
        xdata = plotutil.getplotdata(x)
        ydata = plotutil.getplotdata(y)
        zdata = plotutil.getplotdata(z)  
        style = None
        if len(args) > 0:
            style = args[0]
        
        #Set plot data styles
        label = kwargs.pop('label', 'S_1')
        mvalues = kwargs.pop('mvalues', None)
        if mvalues is None:
            if style is None:
                line = plotutil.getlegendbreak('line', **kwargs)[0]
                line.setCaption(label)
            else:
                line = plotutil.getplotstyle(style, label, **kwargs)
            colors = kwargs.pop('colors', None)
            if not colors is None:
                colors = plotutil.getcolors(colors)
                cbs = []
                for color in colors:
                    cb = line.clone()
                    cb.setColor(color)
                    cbs.append(cb)
        else:
            ls = kwargs.pop('symbolspec', None)
            if ls is None:        
                if isinstance(mvalues, (list, tuple)):
                    mvalues = minum.array(mvalues)
                levels = kwargs.pop('levs', None)
                if levels is None:
                    levels = kwargs.pop('levels', None)
                if levels is None:
                    cnum = kwargs.pop('cnum', None)
                    if cnum is None:
                        ls = plotutil.getlegendscheme([], mvalues.min(), mvalues.max(), **kwargs)
                    else:
                        ls = plotutil.getlegendscheme([cnum], mvalues.min(), mvalues.max(), **kwargs)
                else:
                    ls = plotutil.getlegendscheme([levels], mvalues.min(), mvalues.max(), **kwargs)
                ls = plotutil.setlegendscheme_line(ls, **kwargs)

        #Add graphics
        if mvalues is None:
            if colors is None:
                graphics = GraphicFactory.createLineString3D(xdata, ydata, zdata, line)
            else:
                graphics = GraphicFactory.createLineString3D(xdata, ydata, zdata, cbs)
        else:
            mdata = plotutil.getplotdata(mvalues)
            graphics = GraphicFactory.createLineString3D(xdata, ydata, zdata, mdata, ls)
        visible = kwargs.pop('visible', True)
        if visible:
            self.add_graphic(graphics)
        return graphics
コード例 #7
0
ファイル: axes3d.py プロジェクト: mlog-engineer/MeteoInfo
    def stem(self,
             x,
             y,
             z,
             s=8,
             c='b',
             marker='o',
             alpha=None,
             linewidth=None,
             verts=None,
             **kwargs):
        """
        Make a 3D scatter plot of x, y and z, where x, y and z are sequence like objects of the same lengths.
        
        :param x: (*array_like*) Input x data.
        :param y: (*array_like*) Input y data.
        :param z: (*array_like*) Input z data.
        :param s: (*int*) Size of points.
        :param c: (*Color*) Color of the points. Or z vlaues.
        :param alpha: (*int*) The alpha blending value, between 0 (transparent) and 1 (opaque).
        :param marker: (*string*) Marker of the points.
        :param label: (*string*) Label of the points series.
        :param levs: (*array_like*) Optional. A list of floating point numbers indicating the level 
            points to draw, in increasing order.
        
        :returns: Points legend break.
        """
        #Add data series
        label = kwargs.pop('label', 'S_0')
        xdata = plotutil.getplotdata(x)
        ydata = plotutil.getplotdata(y)
        zdata = plotutil.getplotdata(z)

        #Set plot data styles
        pb, isunique = plotutil.getlegendbreak('point', **kwargs)
        pb.setCaption(label)
        pstyle = plotutil.getpointstyle(marker)
        pb.setStyle(pstyle)
        bottom = kwargs.pop('bottom', 0)
        samestemcolor = kwargs.pop('samestemcolor', False)
        isvalue = False
        if len(c) > 1:
            if isinstance(c, (MIArray, DimArray)):
                isvalue = True
            elif isinstance(c[0], (int, long, float)):
                isvalue = True
        if isvalue:
            ls = kwargs.pop('symbolspec', None)
            if ls is None:
                if isinstance(c, (list, tuple)):
                    c = minum.array(c)
                levels = kwargs.pop('levs', None)
                if levels is None:
                    levels = kwargs.pop('levels', None)
                if levels is None:
                    cnum = kwargs.pop('cnum', None)
                    if cnum is None:
                        ls = plotutil.getlegendscheme([], c.min(), c.max(),
                                                      **kwargs)
                    else:
                        ls = plotutil.getlegendscheme([cnum], c.min(), c.max(),
                                                      **kwargs)
                else:
                    ls = plotutil.getlegendscheme([levels], c.min(), c.max(),
                                                  **kwargs)
                ls = plotutil.setlegendscheme_point(ls, **kwargs)
                if isinstance(s, int):
                    for lb in ls.getLegendBreaks():
                        lb.setSize(s)
                else:
                    n = len(s)
                    for i in range(0, n):
                        ls.getLegendBreaks()[i].setSize(s[i])
            linefmt = kwargs.pop('linefmt', None)
            if linefmt is None:
                linefmt = PolylineBreak()
                linefmt.setColor(Color.black)
            else:
                linefmt = plotutil.getlegendbreak('line', **linefmt)[0]
            #Create graphics
            graphics = GraphicFactory.createStems3D(xdata, ydata, zdata, c.asarray(), \
                ls, linefmt, bottom, samestemcolor)
        else:
            colors = plotutil.getcolors(c, alpha)
            pbs = []
            if isinstance(s, int):
                pb.setSize(s)
                if len(colors) == 1:
                    pb.setColor(colors[0])
                    pb.setOutlineColor(colors[0])
                    pbs.append(pb)
                else:
                    n = len(colors)
                    for i in range(0, n):
                        npb = pb.clone()
                        npb.setColor(colors[i])
                        npb.setOutlineColor(colors[i])
                        pbs.append(npb)
            else:
                n = len(s)
                if len(colors) == 1:
                    pb.setColor(colors[0])
                    pb.setOutlineColor(colors[0])
                    for i in range(0, n):
                        npb = pb.clone()
                        npb.setSize(s[i])
                        pbs.append(npb)
                else:
                    for i in range(0, n):
                        npb = pb.clone()
                        npb.setSize(s[i])
                        npb.setColor(colors[i])
                        npb.setOutlineColor(colors[i])
                        pbs.append(npb)
            linefmt = kwargs.pop('linefmt', None)
            if linefmt is None:
                linefmt = PolylineBreak()
                linefmt.setColor(colors[0])
            else:
                linefmt = plotutil.getlegendbreak('line', **linefmt)[0]
            #Create graphics
            graphics = GraphicFactory.createStems3D(xdata, ydata, zdata, pbs, linefmt, \
                bottom, samestemcolor)

        visible = kwargs.pop('visible', True)
        if visible:
            self.add_graphic(graphics[0])
            self.add_graphic(graphics[1])
        return graphics[0], graphics[1]
コード例 #8
0
ファイル: axes3d.py プロジェクト: mlog-engineer/MeteoInfo
    def plot(self, x, y, z, *args, **kwargs):
        """
        Plot 3D lines and/or markers to the axes. *args* is a variable length argument, allowing
        for multiple *x, y* pairs with an optional format string.
        
        :param x: (*array_like*) Input x data.
        :param y: (*array_like*) Input y data.
        :param z: (*array_like*) Input z data.
        :param style: (*string*) Line style for plot.
        
        :returns: Legend breaks of the lines.
        
        The following format string characters are accepted to control the line style or marker:
        
          =========  ===========
          Character  Description
          =========  ===========
          '-'         solid line style
          '--'        dashed line style
          '-.'        dash-dot line style
          ':'         dotted line style
          '.'         point marker
          ','         pixel marker
          'o'         circle marker
          'v'         triangle_down marker
          '^'         triangle_up marker
          '<'         triangle_left marker
          '>'         triangle_right marker
          's'         square marker
          'p'         pentagon marker
          '*'         star marker
          'x'         x marker
          'D'         diamond marker
          =========  ===========
          
        The following color abbreviations are supported:
          
          =========  =====
          Character  Color  
          =========  =====
          'b'        blue
          'g'        green
          'r'        red
          'c'        cyan
          'm'        magenta
          'y'        yellow
          'k'        black
          =========  =====
        """
        xdata = plotutil.getplotdata(x)
        ydata = plotutil.getplotdata(y)
        zdata = plotutil.getplotdata(z)
        style = None
        if len(args) > 0:
            style = args[0]

        #Set plot data styles
        label = kwargs.pop('label', 'S_1')
        mvalues = kwargs.pop('mvalues', None)
        if mvalues is None:
            if style is None:
                line = plotutil.getlegendbreak('line', **kwargs)[0]
                line.setCaption(label)
            else:
                line = plotutil.getplotstyle(style, label, **kwargs)
            colors = kwargs.pop('colors', None)
            if not colors is None:
                colors = plotutil.getcolors(colors)
                cbs = []
                for color in colors:
                    cb = line.clone()
                    cb.setColor(color)
                    cbs.append(cb)
        else:
            ls = kwargs.pop('symbolspec', None)
            if ls is None:
                if isinstance(mvalues, (list, tuple)):
                    mvalues = minum.array(mvalues)
                levels = kwargs.pop('levs', None)
                if levels is None:
                    levels = kwargs.pop('levels', None)
                if levels is None:
                    cnum = kwargs.pop('cnum', None)
                    if cnum is None:
                        ls = plotutil.getlegendscheme([], mvalues.min(),
                                                      mvalues.max(), **kwargs)
                    else:
                        ls = plotutil.getlegendscheme([cnum], mvalues.min(),
                                                      mvalues.max(), **kwargs)
                else:
                    ls = plotutil.getlegendscheme([levels], mvalues.min(),
                                                  mvalues.max(), **kwargs)
                ls = plotutil.setlegendscheme_line(ls, **kwargs)

        #Add graphics
        if mvalues is None:
            if colors is None:
                graphics = GraphicFactory.createLineString3D(
                    xdata, ydata, zdata, line)
            else:
                graphics = GraphicFactory.createLineString3D(
                    xdata, ydata, zdata, cbs)
        else:
            mdata = plotutil.getplotdata(mvalues)
            graphics = GraphicFactory.createLineString3D(
                xdata, ydata, zdata, mdata, ls)
        visible = kwargs.pop('visible', True)
        if visible:
            self.add_graphic(graphics)
        return graphics
コード例 #9
0
    def plot(self, x, y, z, *args, **kwargs):
        """
        Plot 3D lines and/or markers to the axes. *args* is a variable length argument, allowing
        for multiple *x, y* pairs with an optional format string.
        
        :param x: (*array_like*) Input x data.
        :param y: (*array_like*) Input y data.
        :param z: (*array_like*) Input z data.
        :param style: (*string*) Line style for plot.
        
        :returns: Legend breaks of the lines.
        
        The following format string characters are accepted to control the line style or marker:
        
          =========  ===========
          Character  Description
          =========  ===========
          '-'         solid line style
          '--'        dashed line style
          '-.'        dash-dot line style
          ':'         dotted line style
          '.'         point marker
          ','         pixel marker
          'o'         circle marker
          'v'         triangle_down marker
          '^'         triangle_up marker
          '<'         triangle_left marker
          '>'         triangle_right marker
          's'         square marker
          'p'         pentagon marker
          '*'         star marker
          'x'         x marker
          'D'         diamond marker
          =========  ===========
          
        The following color abbreviations are supported:
          
          =========  =====
          Character  Color  
          =========  =====
          'b'        blue
          'g'        green
          'r'        red
          'c'        cyan
          'm'        magenta
          'y'        yellow
          'k'        black
          =========  =====
        """      
        xdata = plotutil.getplotdata(x)
        ydata = plotutil.getplotdata(y)
        zdata = plotutil.getplotdata(z)  
        style = None
        if len(args) > 0:
            style = args[0]
        
        #Set plot data styles
        label = kwargs.pop('label', 'S_1')
        if style is None:
            line = plotutil.getlegendbreak('line', **kwargs)[0]
            line.setCaption(label)
        else:
            line = plotutil.getplotstyle(style, label, **kwargs)   

        #Add graphics
        graphics = GraphicFactory.createLineString(xdata, ydata, zdata, line)
        visible = kwargs.pop('visible', True)
        if visible:
            self.add_graphic(graphics)
            miplot.draw_if_interactive()
        return graphics
コード例 #10
0
    def plot_isosurface(self, *args, **kwargs):
        '''
        creates a three-dimensional isosurface plot

        :param x: (*array_like*) Optional. X coordinate array.
        :param y: (*array_like*) Optional. Y coordinate array.
        :param z: (*array_like*) Optional. Z coordinate array.
        :param data: (*array_like*) 3D data array.
        :param cmap: (*string*) Color map string.
        :param nthread: (*int*) Thread number.

        :returns: Legend
        '''
        warnings.warn("plot_isosurface is deprecated", DeprecationWarning)
        if len(args) <= 3:
            x = args[0].dimvalue(2)
            y = args[0].dimvalue(1)
            z = args[0].dimvalue(0)
            data = args[0]
            isovalue = args[1]
            args = args[2:]
        else:
            x = args[0]
            y = args[1]
            z = args[2]
            data = args[3]
            isovalue = args[4]
            args = args[5:]
        cmap = plotutil.getcolormap(**kwargs)
        cvalue = kwargs.pop('cvalue', None)
        if not cvalue is None:
            if len(args) > 0:
                level_arg = args[0]
                if isinstance(level_arg, int):
                    cn = level_arg
                    ls = LegendManage.createLegendScheme(
                        data.min(), data.max(), cn, cmap)
                else:
                    if isinstance(level_arg, NDArray):
                        level_arg = level_arg.aslist()
                    ls = LegendManage.createLegendScheme(
                        data.min(), data.max(), level_arg, cmap)
            else:
                ls = LegendManage.createLegendScheme(data.min(), data.max(),
                                                     cmap)
            ls = ls.convertTo(ShapeTypes.Polygon)
            edge = kwargs.pop('edge', True)
            kwargs['edge'] = edge
            plotutil.setlegendscheme(ls, **kwargs)
        else:
            ls = plotutil.getlegendbreak('polygon', **kwargs)[0]
        nthread = kwargs.pop('nthread', None)
        if nthread is None:
            graphics = JOGLUtil.isosurface(data.asarray(), x.asarray(),
                                           y.asarray(), z.asarray(), isovalue,
                                           ls)
        else:
            data = data.asarray().copyIfView()
            x = x.asarray().copyIfView()
            y = y.asarray().copyIfView()
            z = z.asarray().copyIfView()
            graphics = JOGLUtil.isosurface(data, x, y, z, isovalue, ls,
                                           nthread)
        visible = kwargs.pop('visible', True)
        if visible:
            self.add_graphic(graphics)
        return graphics