Esempio n. 1
0
 def contourf(self, *args, **kwargs):  
     """
     Plot filled contours on the map.
     
     :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 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 smooth: (*boolean*) Smooth countour lines or not.
     :param select: (*boolean*) Set the return layer as selected layer or not.
     
     :returns: (*VectoryLayer*) Contour VectoryLayer created from array data.
     """
     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:]
     ls = plotutil.getlegendscheme(args, a.min(), a.max(), **kwargs)
     ls = ls.convertTo(ShapeTypes.Polygon)
     plotutil.setlegendscheme(ls, **kwargs)
     isadd = kwargs.pop('isadd', True)
     smooth = kwargs.pop('smooth', True)
     layer = DrawMeteoData.createShadedLayer(a.array, x.array, y.array, ls, 'layer', 'data', smooth)
     proj = kwargs.pop('proj', None)
     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)
Esempio n. 2
0
    def imshow(self, *args, **kwargs):
        """
        Display an image on the 3D axes.
        
        :param x: (*array_like*) Optional. X coordinate array.
        :param y: (*array_like*) Optional. Y coordinate array.
        :param z: (*array_like*) 2-D or 3-D (RGB) 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.
        
        :returns: (*RasterLayer*) RasterLayer created from array data.
        """
        n = len(args)
        cmap = plotutil.getcolormap(**kwargs)
        fill_value = kwargs.pop('fill_value', -9999.0)
        xaxistype = None
        isrgb = False
        if n <= 2:
            if isinstance(args[0], (list, tuple)):
                isrgb = True
                rgbdata = args[0]
                if isinstance(rgbdata[0], NDArray):
                    x = np.arange(0, rgbdata[0].shape[1])
                    y = np.arange(0, rgbdata[0].shape[0])
                else:
                    x = rgbdata[0].dimvalue(1)
                    y = rgbdata[0].dimvalue(0)
            elif args[0].ndim > 2:
                isrgb = True
                rgbdata = args[0]
                if isinstance(rgbdata, NDArray):
                    x = np.arange(0, rgbdata.shape[1])
                    y = np.arange(0, rgbdata.shape[0])
                else:
                    x = rgbdata.dimvalue(1)
                    y = rgbdata.dimvalue(0)
            else:
                gdata = np.asgridarray(args[0])
                if isinstance(args[0], DimArray):
                    if args[0].islondim(1):
                        xaxistype = 'lon'
                    elif args[0].islatdim(1):
                        xaxistype = 'lat'
                    elif args[0].istimedim(1):
                        xaxistype = 'time'
                args = args[1:]
        elif n <= 4:
            x = args[0]
            y = args[1]
            a = args[2]
            if isinstance(a, (list, tuple)):
                isrgb = True
                rgbdata = a
            elif a.ndim > 2:
                isrgb = True
                rgbdata = a
            else:
                gdata = np.asgridarray(a, x, y, fill_value)
                args = args[3:]

        offset = kwargs.pop('offset', 0)
        zdir = kwargs.pop('zdir', 'z')
        interpolation = kwargs.pop('interpolation', None)
        if isrgb:
            if isinstance(rgbdata, (list, tuple)):
                rgbd = []
                for d in rgbdata:
                    rgbd.append(d.asarray())
                rgbdata = rgbd
            else:
                rgbdata = rgbdata.asarray()
            x = plotutil.getplotdata(x)
            y = plotutil.getplotdata(y)
            graphics = GraphicFactory.createImage(x, y, rgbdata, offset, zdir,
                                                  interpolation)
            ls = None
        else:
            if len(args) > 0:
                level_arg = args[0]
                if isinstance(level_arg, int):
                    cn = level_arg
                    ls = LegendManage.createImageLegend(gdata, cn, cmap)
                else:
                    if isinstance(level_arg, NDArray):
                        level_arg = level_arg.aslist()
                    ls = LegendManage.createImageLegend(gdata, level_arg, cmap)
            else:
                ls = plotutil.getlegendscheme(args, gdata.min(), gdata.max(),
                                              **kwargs)
            ls = ls.convertTo(ShapeTypes.Image)
            plotutil.setlegendscheme(ls, **kwargs)
            if zdir == 'xy':
                sepoint = kwargs.pop('sepoint', [0, 0, 1, 1])
            else:
                sepoint = None
            graphics = GraphicFactory.createImage(gdata, ls, offset, zdir,
                                                  sepoint, interpolation)

        visible = kwargs.pop('visible', True)
        if visible:
            self.add_graphic(graphics)
        return graphics
Esempio n. 3
0
    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, (NDArray, 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 = np.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]
Esempio n. 4
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')
        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 = np.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
Esempio n. 5
0
    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)
Esempio n. 6
0
 def scatter(self, *args, **kwargs):
     """
     Make a scatter plot on a map.
     
     :param x: (*array_like*) Input x data.
     :param y: (*array_like*) Input y data.
     :param z: (*array_like*) Input z data.
     :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, different 
         levels will be plotted in different colors in the order specified.
     :param size: (*int of list*) Marker size.
     :param marker: (*string*) Marker of the points.
     :param fill: (*boolean*) Fill markers or not. Default is True.
     :param edge: (*boolean*) Draw edge of markers or not. Default is True.
     :param facecolor: (*Color*) Fill color of markers. Default is black.
     :param edgecolor: (*Color*) Edge color of markers. Default is black.
     :param proj: (*ProjectionInfo*) Map projection of the data. Default is None.
     :param zorder: (*int*) Z-order of created layer for display.
     
     :returns: (*VectoryLayer*) Point VectoryLayer.
     """
     n = len(args) 
     if n == 1:
         a = args[0]
         y = a.dimvalue(0)
         x = a.dimvalue(1)
         args = args[1:]
     else:
         x = args[0]
         y = args[1]
         if not isinstance(x, MIArray):
             x = minum.array(x)
         if not isinstance(y, MIArray):
             y = minum.array(y)
         if n == 2:
             a = x
             args = args[2:]
         else:
             a = args[2]
             if not isinstance(a, MIArray):
                 a = minum.array(a)
             args = args[3:]
     
     ls = kwargs.pop('symbolspec', None)
     if ls is None:
         isunique = False
         colors = kwargs.get('colors', None) 
         if not colors is None:
             if isinstance(colors, (list, tuple)) and len(colors) == len(x):
                 isunique = True
         size = kwargs.get('size', None)
         if not size is None:
             if isinstance(size, (list, tuple, MIArray)) and len(size) == len(x):
                 isunique = True
         if isunique:
             ls = LegendManage.createUniqValueLegendScheme(len(x), ShapeTypes.Point)
         else:
             ls = plotutil.getlegendscheme(args, a.min(), a.max(), **kwargs)
         ls = plotutil.setlegendscheme_point(ls, **kwargs)
     
     if a.size == ls.getBreakNum() and ls.getLegendType() == LegendType.UniqueValue:
         layer = DrawMeteoData.createSTPointLayer_Unique(a.array, x.array, y.array, ls, 'layer', 'data')
     else:
         layer = DrawMeteoData.createSTPointLayer(a.array, x.array, y.array, ls, 'layer', 'data')
     
     proj = kwargs.pop('proj', None)
     if not proj is None:
         layer.setProjInfo(proj)
     avoidcoll = kwargs.pop('avoidcoll', None)
     if not avoidcoll is None:
         layer.setAvoidCollision(avoidcoll)
     
     # Add layer
     isadd = kwargs.pop('isadd', True)
     if isadd:
         zorder = kwargs.pop('zorder', None)
         select = kwargs.pop('select', True)
         self.add_layer(layer, zorder, select)
         self.axes.setDrawExtent(layer.getExtent().clone())
         self.axes.setExtent(layer.getExtent().clone())
     
     return MILayer(layer)
Esempio n. 7
0
 def imshow(self, *args, **kwargs):
     """
     Display an image on the 3D axes.
     
     :param x: (*array_like*) Optional. X coordinate array.
     :param y: (*array_like*) Optional. Y coordinate array.
     :param z: (*array_like*) 2-D or 3-D (RGB) 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.
     
     :returns: (*RasterLayer*) RasterLayer created from array data.
     """
     n = len(args)
     cmap = plotutil.getcolormap(**kwargs)
     fill_value = kwargs.pop('fill_value', -9999.0)
     xaxistype = None
     isrgb = False
     if n <= 2:
         if isinstance(args[0], (list, tuple)):
             isrgb = True
             rgbdata = args[0]
             if isinstance(rgbdata[0], MIArray):
                 x = minum.arange(0, rgbdata[0].shape[1])
                 y = minum.arange(0, rgbdata[0].shape[0])
             else:
                 x = rgbdata[0].dimvalue(1)
                 y = rgbdata[0].dimvalue(0)
         elif args[0].ndim > 2:
             isrgb = True
             rgbdata = args[0]
             if isinstance(rgbdata, MIArray):
                 x = minum.arange(0, rgbdata.shape[1])
                 y = minum.arange(0, rgbdata.shape[0])
             else:
                 x = rgbdata.dimvalue(1)
                 y = rgbdata.dimvalue(0)
         else:
             gdata = minum.asgridarray(args[0])
             if isinstance(args[0], DimArray):
                 if args[0].islondim(1):
                     xaxistype = 'lon'
                 elif args[0].islatdim(1):
                     xaxistype = 'lat'
                 elif args[0].istimedim(1):
                     xaxistype = 'time'
             args = args[1:]
     elif n <=4:
         x = args[0]
         y = args[1]
         a = args[2]
         if isinstance(a, (list, tuple)):
             isrgb = True
             rgbdata = a
         elif a.ndim > 2:
             isrgb = True
             rgbdata = a
         else:
             gdata = minum.asgridarray(a, x, y, fill_value)
             args = args[3:]   
     
     offset = kwargs.pop('offset', 0)
     zdir = kwargs.pop('zdir', 'z')
     interpolation = kwargs.pop('interpolation', None)
     if isrgb:
         if isinstance(rgbdata, (list, tuple)):
             rgbd = []
             for d in rgbdata:
                 rgbd.append(d.asarray())
             rgbdata = rgbd
         else:
             rgbdata = rgbdata.asarray()
         x = plotutil.getplotdata(x)
         y = plotutil.getplotdata(y)
         graphics = GraphicFactory.createImage(x, y, rgbdata, offset, zdir, interpolation)
         ls = None
     else:
         if len(args) > 0:
             level_arg = args[0]
             if isinstance(level_arg, int):
                 cn = level_arg
                 ls = LegendManage.createImageLegend(gdata, cn, cmap)
             else:
                 if isinstance(level_arg, MIArray):
                     level_arg = level_arg.aslist()
                 ls = LegendManage.createImageLegend(gdata, level_arg, cmap)
         else:
             ls = plotutil.getlegendscheme(args, gdata.min(), gdata.max(), **kwargs)
         ls = ls.convertTo(ShapeTypes.Image)
         plotutil.setlegendscheme(ls, **kwargs)
         if zdir == 'xy':
             sepoint = kwargs.pop('sepoint', [0,0,1,1])
         else:
             sepoint = None
         graphics = GraphicFactory.createImage(gdata, ls, offset, zdir, sepoint, interpolation)
             
     visible = kwargs.pop('visible', True)
     if visible:
         self.add_graphic(graphics)
     return graphics
Esempio n. 8
0
 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]
Esempio n. 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')
        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