def bar(self, x, y, z, width=0.8, bottom=None, cylinder=False, **kwargs): """ Make a 3D bar 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 width: (*float*) Bar width. :param cylinder: (*bool*) Is sylinder bar or rectangle bar. :param bottom: (*bool*) Color of the points. Or z vlaues. :param color: (*Color*) Optional, the color of the bar faces. :param edgecolor: (*Color*) Optional, the color of the bar edge. Default is black color. Edge line will not be plotted if ``edgecolor`` is ``None``. :param linewidth: (*int*) Optional, width of bar edge. :param label: (*string*) Label of the bar series. :param hatch: (*string*) Hatch string. :param hatchsize: (*int*) Hatch size. Default is None (8). :param bgcolor: (*Color*) Background color, only valid with hatch. :param barswidth: (*float*) Bars width (0 - 1), only used for automatic bar with plot (only one argument widthout ``width`` augument). Defaul is 0.8. :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) autowidth = False width = np.asarray(width) if not bottom is None: bottom = plotutil.getplotdata(bottom) #Set plot data styles fcobj = kwargs.pop('color', None) if fcobj is None: fcobj = kwargs.pop('facecolor', 'b') if isinstance(fcobj, (tuple, list)): colors = plotutil.getcolors(fcobj) else: color = plotutil.getcolor(fcobj) colors = [color] ecobj = kwargs.pop('edgecolor', 'k') edgecolor = plotutil.getcolor(ecobj) linewidth = kwargs.pop('linewidth', 1.0) hatch = kwargs.pop('hatch', None) hatch = plotutil.gethatch(hatch) hatchsize = kwargs.pop('hatchsize', None) bgcolor = kwargs.pop('bgcolor', None) bgcolor = plotutil.getcolor(bgcolor) ecolor = kwargs.pop('ecolor', 'k') ecolor = plotutil.getcolor(ecolor) barbreaks = [] for color in colors: lb = BarBreak() lb.setCaption(label) lb.setColor(color) if edgecolor is None: lb.setDrawOutline(False) else: lb.setOutlineColor(edgecolor) lb.setOutlineSize(linewidth) if not hatch is None: lb.setStyle(hatch) if not bgcolor is None: lb.setBackColor(bgcolor) if not hatchsize is None: lb.setStyleSize(hatchsize) lb.setErrorColor(ecolor) barbreaks.append(lb) #Create bar graphics if isinstance(width, NDArray): width = width.asarray() if cylinder: graphics = GraphicFactory.createCylinderBars3D( xdata, ydata, zdata, autowidth, width, bottom, barbreaks) else: graphics = GraphicFactory.createBars3D(xdata, ydata, zdata, autowidth, width, bottom, barbreaks) self.add_graphic(graphics) return barbreaks
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]
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]
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
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