def makesymbolspec(geometry, *args, **kwargs): ''' Make a legend. :param geometry: (*string*) Geometry type. [point | line | polygon]. :param levels: (*array_like*) Value levels. Default is ``None``, not used. :param colors: (*list*) Colors. Defaul is ``None``, not used. :param legend break parameter maps: (*map*) Legend breaks. :param field: (*string*) The field to be used in the legend. :returns: Created legend. ''' shapetype = ShapeTypes.Image if geometry == 'point': shapetype = ShapeTypes.Point elif geometry == 'line': shapetype = ShapeTypes.Polyline elif geometry == 'polygon': shapetype = ShapeTypes.Polygon else: shapetype = ShapeTypes.Image levels = kwargs.pop('levels', None) cols = kwargs.pop('colors', None) field = kwargs.pop('field', '') if not levels is None and not cols is None: if isinstance(levels, MIArray): levels = levels.aslist() colors = [] for cobj in cols: colors.append(getcolor(cobj)) ls = LegendManage.createLegendScheme(shapetype, levels, colors) setlegendscheme(ls, **kwargs) ls.setFieldName(field) values = kwargs.pop('values', None) if values is None: return ls else: nls = LegendScheme(ls.getShapeType()) for v in values: nls.addLegendBreak(ls.findLegendBreak(v)) return nls n = len(args) isunique = True if n == 0: ls = LegendManage.createSingleSymbolLegendScheme(shapetype) setlegendscheme(ls, **kwargs) elif n == 1 and isinstance(args[0], int): ls = LegendManage.createUniqValueLegendScheme(args[0], shapetype) setlegendscheme(ls, **kwargs) else: ls = LegendScheme(shapetype) for arg in args: if isinstance(arg, (list, tuple)): for argi in arg: lb, isu = getlegendbreak(geometry, **argi) if isunique and not isu: isunique = False ls.addLegendBreak(lb) else: lb, isu = getlegendbreak(geometry, **arg) if isunique and not isu: isunique = False ls.addLegendBreak(lb) ls.setFieldName(field) if ls.getBreakNum() > 1: if isunique: ls.setLegendType(LegendType.UniqueValue) else: ls.setLegendType(LegendType.GraduatedColor) return ls
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)