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
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:] zcolors = kwargs.pop('zcolors', False) if not zcolors: line = plotutil.getlegendbreak('line', **kwargs)[0] graphics = GraphicFactory.createWireframe(x.asarray(), y.asarray(), z.asarray(), line) else: cmap = plotutil.getcolormap(**kwargs) if len(args) > 0: level_arg = args[0] if isinstance(level_arg, int): cn = level_arg ls = LegendManage.createLegendScheme( z.min(), z.max(), cn, cmap) else: if isinstance(level_arg, NDArray): level_arg = level_arg.aslist() ls = LegendManage.createLegendScheme( z.min(), z.max(), level_arg, cmap) else: ls = LegendManage.createLegendScheme(z.min(), z.max(), cmap) ls = ls.convertTo(ShapeTypes.Polyline) plotutil.setlegendscheme(ls, **kwargs) graphics = GraphicFactory.createWireframe(x.asarray(), y.asarray(), z.asarray(), ls) visible = kwargs.pop('visible', True) if visible: self.add_graphic(graphics) return graphics
def plot_surface(self, *args, **kwargs): ''' creates a three-dimensional surface 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) <= 2: 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:] cmap = plotutil.getcolormap(**kwargs) if len(args) > 0: level_arg = args[0] if isinstance(level_arg, int): cn = level_arg ls = LegendManage.createLegendScheme(z.min(), z.max(), cn, cmap) else: if isinstance(level_arg, MIArray): level_arg = level_arg.aslist() ls = LegendManage.createLegendScheme(z.min(), z.max(), level_arg, cmap) else: ls = LegendManage.createLegendScheme(z.min(), z.max(), cmap) ls = ls.convertTo(ShapeTypes.Polygon) edge = kwargs.pop('edge', True) kwargs['edge'] = edge plotutil.setlegendscheme(ls, **kwargs) graphics = GraphicFactory.createMeshPolygons(x.asarray(), y.asarray(), z.asarray(), ls) visible = kwargs.pop('visible', True) if visible: self.add_graphic(graphics) miplot.draw_if_interactive() return graphics
def plot_surface(self, *args, **kwargs): ''' creates a three-dimensional surface 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) <= 2: 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:] cmap = plotutil.getcolormap(**kwargs) if len(args) > 0: level_arg = args[0] if isinstance(level_arg, int): cn = level_arg ls = LegendManage.createLegendScheme(z.min(), z.max(), cn, cmap) else: if isinstance(level_arg, MIArray): level_arg = level_arg.aslist() ls = LegendManage.createLegendScheme(z.min(), z.max(), level_arg, cmap) else: ls = LegendManage.createLegendScheme(z.min(), z.max(), cmap) ls = ls.convertTo(ShapeTypes.Polygon) edge = kwargs.pop('edge', True) kwargs['edge'] = edge plotutil.setlegendscheme(ls, **kwargs) graphics = GraphicFactory.createMeshPolygons(x.asarray(), y.asarray(), z.asarray(), ls) visible = kwargs.pop('visible', True) if visible: self.add_graphic(graphics) return graphics
def barbs(self, *args, **kwargs): """ Plot a 2-D field of barbs in a map. :param x: (*array_like*) Optional. X coordinate array. :param y: (*array_like*) Optional. Y coordinate array. :param u: (*array_like*) U component of the arrow vectors (wind field) or wind direction. :param v: (*array_like*) V component of the arrow vectors (wind field) or wind speed. :param z: (*array_like*) Optional, 2-D z value array. :param levs: (*array_like*) Optional. A list of floating point numbers indicating the level barbs to draw, in increasing order. :param cmap: (*string*) Color map string. :param fill_value: (*float*) Fill_value. Default is ``-9999.0``. :param isuv: (*boolean*) Is U/V or direction/speed data array pairs. Default is True. :param size: (*float*) Base size of the arrows. :param proj: (*ProjectionInfo*) Map projection of the data. Default is None. :param zorder: (*int*) Z-order of created layer for display. :param select: (*boolean*) Set the return layer as selected layer or not. :returns: (*VectoryLayer*) Created barbs VectoryLayer. """ cmap = plotutil.getcolormap(**kwargs) fill_value = kwargs.pop('fill_value', -9999.0) proj = kwargs.pop('proj', None) order = kwargs.pop('order', None) isuv = kwargs.pop('isuv', True) n = len(args) iscolor = False cdata = None onlyuv = True if n >= 4 and isinstance(args[3], (DimArray, MIArray)): onlyuv = False if onlyuv: u = minum.asarray(args[0]) v = minum.asarray(args[1]) xx = args[0].dimvalue(1) yy = args[0].dimvalue(0) x, y = minum.meshgrid(xx, yy) args = args[2:] if len(args) > 0: cdata = minum.asarray(args[0]) iscolor = True args = args[1:] else: x = minum.asarray(args[0]) y = minum.asarray(args[1]) u = minum.asarray(args[2]) v = minum.asarray(args[3]) args = args[4:] if len(args) > 0: cdata = minum.asarray(args[0]) iscolor = True args = args[1:] if iscolor: if len(args) > 0: cn = args[0] ls = LegendManage.createLegendScheme(cdata.min(), cdata.max(), cn, cmap) else: levs = kwargs.pop('levs', None) if levs is None: ls = LegendManage.createLegendScheme(cdata.min(), cdata.max(), cmap) else: if isinstance(levs, MIArray): levs = levs.tolist() ls = LegendManage.createLegendScheme(cdata.min(), cdata.max(), levs, cmap) else: if cmap.getColorCount() == 1: c = cmap.getColor(0) else: c = Color.black ls = LegendManage.createSingleSymbolLegendScheme(ShapeTypes.Point, c, 10) ls = plotutil.setlegendscheme_point(ls, **kwargs) if not cdata is None: cdata = cdata.array layer = DrawMeteoData.createBarbLayer(x.array, y.array, u.array, v.array, cdata, ls, 'layer', isuv) 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) self.add_layer(layer, zorder, select) self.axes.setDrawExtent(layer.getExtent().clone()) self.axes.setExtent(layer.getExtent().clone()) return MILayer(layer)
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)