def contourf(self, *args, **kwargs): """ Plot filled contours. :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 smooth: (*boolean*) Smooth countour lines or not. :returns: (*VectoryLayer*) Contour VectoryLayer created from array data. """ n = len(args) cmap = plotutil.getcolormap(**kwargs) fill_value = kwargs.pop('fill_value', -9999.0) offset = kwargs.pop('offset', 0) xaxistype = None if n <= 2: gdata = minum.asgriddata(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] gdata = minum.asgriddata(a, x, y, fill_value) args = args[3:] if len(args) > 0: level_arg = args[0] if isinstance(level_arg, int): cn = level_arg ls = LegendManage.createLegendScheme(gdata.min(), gdata.max(), cn, cmap) else: if isinstance(level_arg, MIArray): level_arg = level_arg.aslist() ls = LegendManage.createLegendScheme(gdata.min(), gdata.max(), level_arg, cmap) else: ls = LegendManage.createLegendScheme(gdata.min(), gdata.max(), cmap) ls = ls.convertTo(ShapeTypes.Polygon) edge = kwargs.pop('edge', None) if edge is None: kwargs['edge'] = False else: kwargs['edge'] = edge plotutil.setlegendscheme(ls, **kwargs) smooth = kwargs.pop('smooth', True) zdir = kwargs.pop('zdir', 'z') if zdir == 'xy': sepoint = kwargs.pop('sepoint', [0, 0, 1, 1]) igraphic = GraphicFactory.createContourPolygons(gdata.data, offset, zdir, ls, smooth, \ sepoint) else: igraphic = GraphicFactory.createContourPolygons( gdata.data, offset, zdir, ls, smooth) visible = kwargs.pop('visible', True) if visible: self.add_graphic(igraphic) return igraphic
def contourf(self, *args, **kwargs): """ Plot filled contours. :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 smooth: (*boolean*) Smooth countour lines or not. :returns: (*VectoryLayer*) Contour VectoryLayer created from array data. """ n = len(args) cmap = plotutil.getcolormap(**kwargs) fill_value = kwargs.pop('fill_value', -9999.0) offset = kwargs.pop('offset', 0) xaxistype = None if n <= 2: gdata = minum.asgriddata(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] gdata = minum.asgriddata(a, x, y, fill_value) args = args[3:] if len(args) > 0: level_arg = args[0] if isinstance(level_arg, int): cn = level_arg ls = LegendManage.createLegendScheme(gdata.min(), gdata.max(), cn, cmap) else: if isinstance(level_arg, MIArray): level_arg = level_arg.aslist() ls = LegendManage.createLegendScheme(gdata.min(), gdata.max(), level_arg, cmap) else: ls = LegendManage.createLegendScheme(gdata.min(), gdata.max(), cmap) ls = ls.convertTo(ShapeTypes.Polygon) edge = kwargs.pop('edge', None) if edge is None: kwargs['edge'] = False else: kwargs['edge'] = edge plotutil.setlegendscheme(ls, **kwargs) smooth = kwargs.pop('smooth', True) zdir = kwargs.pop('zdir', 'z') if zdir == 'xy': sepoint = kwargs.pop('sepoint', [0,0,1,1]) igraphic = GraphicFactory.createContourPolygons(gdata.data, offset, zdir, ls, smooth, \ sepoint) else: igraphic = GraphicFactory.createContourPolygons(gdata.data, offset, zdir, ls, smooth) visible = kwargs.pop('visible', True) if visible: self.add_graphic(igraphic) return igraphic