Пример #1
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
Пример #2
0
 def plot(self, *args, **kwargs):
     """
     Plot lines and/or markers to the map.
     
     :param x: (*array_like*) Input x data.
     :param y: (*array_like*) Input y data.
     :param style: (*string*) Line style for plot.
     :param linewidth: (*float*) Line width.
     :param color: (*Color*) Line color.
     
     :returns: (*VectoryLayer*) Line VectoryLayer.
     """
     fill_value = kwargs.pop('fill_value', -9999.0)
     proj = kwargs.pop('proj', None)    
     order = kwargs.pop('order', None)
     n = len(args) 
     xdatalist = []
     ydatalist = []    
     styles = []
     if n == 1:
         ydata = plotutil.getplotdata(args[0])
         if isinstance(args[0], DimArray):
             xdata = args[0].dimvalue(0)
         else:
             xdata = []
             for i in range(0, len(args[0])):
                 xdata.append(i)
         xdatalist.append(minum.asarray(xdata).array)
         ydatalist.append(minum.asarray(ydata).array)
     elif n == 2:
         if isinstance(args[1], basestring):
             ydata = plotutil.getplotdata(args[0])
             if isinstance(args[0], DimArray):
                 xdata = args[0].dimvalue(0)
             else:
                 xdata = []
                 for i in range(0, len(args[0])):
                     xdata.append(i)
             styles.append(args[1])
         else:
             xdata = plotutil.getplotdata(args[0])
             ydata = plotutil.getplotdata(args[1])
         xdatalist.append(minum.asarray(xdata).array)
         ydatalist.append(minum.asarray(ydata).array)
     else:
         c = 'x'
         for arg in args: 
             if c == 'x':    
                 xdatalist.append(minum.asarray(arg).array)
                 c = 'y'
             elif c == 'y':
                 ydatalist.append(minum.asarray(arg).array)
                 c = 's'
             elif c == 's':
                 if isinstance(arg, basestring):
                     styles.append(arg)
                     c = 'x'
                 else:
                     styles.append('-')
                     xdatalist.append(minum.asarray(arg).array)
                     c = 'y'
     
     snum = len(xdatalist)
         
     if len(styles) == 0:
         styles = None
     else:
         while len(styles) < snum:
             styles.append('-')
     
     #Get plot data styles - Legend
     lines = []
     ls = kwargs.pop('legend', None) 
     if ls is None:
         if styles != None:
             for i in range(0, len(styles)):
                 line = plotutil.getplotstyle(styles[i], str(i), **kwargs)
                 lines.append(line)
         else:
             for i in range(0, snum):
                 label = kwargs.pop('label', 'S_' + str(i + 1))
                 line = plotutil.getlegendbreak('line', **kwargs)[0]
                 line.setCaption(label)
                 lines.append(line)
         ls = LegendScheme(lines)
     
     layer = DrawMeteoData.createPolylineLayer(xdatalist, ydatalist, ls, \
             'Plot_lines', 'ID', -180, 180)
     if (proj != None):
         layer.setProjInfo(proj)
  
     # 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)
Пример #3
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)
        return graphics
Пример #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 = 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