def mcurve(self, *args, **kwargs): """ Make a curve `plot item` based on MATLAB-like syntax (may returns a list of curves if data contains more than one signal) (:py:class:`guiqwt.curve.CurveItem` object) Example:: mcurve(x, y, 'r+') """ x, y, style = self.__get_arg_triple_plot(args) if isinstance(y, ndarray): y = [y] if not isinstance(style, list): style = [style] if len(y) > len(style): style = [style[0]] * len(y) basename = _("Curve") curves = [] for yi, stylei in zip(y, style): param = CurveParam(title=basename, icon="curve.png") if "label" in kwargs: param.label = kwargs.pop("label") else: global CURVE_COUNT CURVE_COUNT += 1 param.label = make_title(basename, CURVE_COUNT) update_style_attr(stylei, param) curves.append(self.pcurve(x, yi, param, **kwargs)) if len(curves) == 1: return curves[0] else: return curves
def mcurve(self, *args, **kwargs): """ Make a curve `plot item` based on MATLAB-like syntax (may returns a list of curves if data contains more than one signal) (:py:class:`guiqwt.curve.CurveItem` object) Example:: mcurve(x, y, 'r+') """ x, y, style = self.__get_arg_triple_plot(args) if isinstance(y, ndarray): y = [y] if not isinstance(style, list): style = [style] if len(y) > len(style): style = [style[0]]*len(y) basename = _("Curve") curves = [] for yi, stylei in zip(y, style): param = CurveParam(title=basename, icon='curve.png') if "label" in kwargs: param.label = kwargs.pop("label") else: global CURVE_COUNT CURVE_COUNT += 1 param.label = make_title(basename, CURVE_COUNT) update_style_attr(stylei, param) curves.append(self.pcurve(x, yi, param, **kwargs)) if len(curves) == 1: return curves[0] else: return curves
def create_curves(self, labels, this_range, show_legend=True): self.curves = [] plot = self.get_plot() plot.del_all_items(except_grid=False) for i, l in enumerate(labels): param = CurveParam() param.label = str(l) color = COLORS.get(self.colors[i % len(self.colors)], self.colors[i % len(self.colors)]) param.line.color = color # create a new curve curve = CurveItemModel(param) self.curves.append(curve) plot.add_item(curve) curve.setRenderHint(QwtPlotItem.RenderAntialiased, USE_ANTIALIASING) l = make.legend("TR") if show_legend: plot.add_item(l) self.myranges = [] for r in this_range: self.add_range_to_plot(plot, r)
def histogram( self, data, bins=None, logscale=None, title="", color=None, xaxis="bottom", yaxis="left", ): """ Make 1D Histogram `plot item` (:py:class:`guiqwt.histogram.HistogramItem` object) * data (1D NumPy array) * bins: number of bins (int) * logscale: Y-axis scale (bool) """ basename = _("Histogram") histparam = HistogramParam(title=basename, icon="histogram.png") curveparam = CurveParam(_("Curve"), icon="curve.png") curveparam.read_config(CONF, "histogram", "curve") if not title: global HISTOGRAM_COUNT HISTOGRAM_COUNT += 1 title = make_title(basename, HISTOGRAM_COUNT) curveparam.label = title if color is not None: curveparam.line.color = color if bins is not None: histparam.n_bins = bins if logscale is not None: histparam.logscale = logscale return self.phistogram(data, curveparam, histparam, xaxis, yaxis)
def histogram(self, data, bins=None, logscale=None, title="", color=None, xaxis="bottom", yaxis="left"): """ Make 1D Histogram `plot item` (:py:class:`guiqwt.histogram.HistogramItem` object) * data (1D NumPy array) * bins: number of bins (int) * logscale: Y-axis scale (bool) """ basename = _("Histogram") histparam = HistogramParam(title=basename, icon='histogram.png') curveparam = CurveParam(_("Curve"), icon='curve.png') curveparam.read_config(CONF, "histogram", "curve") if not title: global HISTOGRAM_COUNT HISTOGRAM_COUNT += 1 title = make_title(basename, HISTOGRAM_COUNT) curveparam.label = title if color is not None: curveparam.line.color = color if bins is not None: histparam.n_bins = bins if logscale is not None: histparam.logscale = logscale return self.phistogram(data, curveparam, histparam, xaxis, yaxis)
def merror(self, *args, **kwargs): """ Make an errorbar curve `plot item` based on MATLAB-like syntax (:py:class:`guiqwt.curve.ErrorBarCurveItem` object) Example:: mcurve(x, y, 'r+') """ x, y, dx, dy, style = self.__get_arg_triple_errorbar(args) basename = _("Curve") curveparam = CurveParam(title=basename, icon="curve.png") errorbarparam = ErrorBarParam(title=_("Error bars"), icon="errorbar.png") if "label" in kwargs: curveparam.label = kwargs["label"] else: global CURVE_COUNT CURVE_COUNT += 1 curveparam.label = make_title(basename, CURVE_COUNT) update_style_attr(style, curveparam) errorbarparam.color = curveparam.line.color return self.perror(x, y, dx, dy, curveparam, errorbarparam)
def merror(self, *args, **kwargs): """ Make an errorbar curve `plot item` based on MATLAB-like syntax (:py:class:`guiqwt.curve.ErrorBarCurveItem` object) Example:: mcurve(x, y, 'r+') """ x, y, dx, dy, style = self.__get_arg_triple_errorbar(args) basename = _("Curve") curveparam = CurveParam(title=basename, icon="curve.png") errorbarparam = ErrorBarParam(title=_("Error bars"), icon="errorbar.png") if "label" in kwargs: curveparam.label = kwargs["label"] else: global CURVE_COUNT CURVE_COUNT += 1 curveparam.label = make_title(basename, CURVE_COUNT) update_style_attr(style, curveparam) errorbarparam.color = curveparam.line.color return self.perror(x, y, dx, dy, curveparam, errorbarparam)
def create_curves(self, labels, this_range, show_legend=True): self.curves = [] plot = self.get_plot() plot.del_all_items(except_grid=False) for i,l in enumerate(labels): param = CurveParam() param.label = str(l) color = COLORS.get(self.colors[i % len(self.colors)], self.colors[i % len(self.colors)] ) param.line.color = color # create a new curve curve = CurveItemModel(param) self.curves.append(curve) plot.add_item( curve ) curve.setRenderHint(QwtPlotItem.RenderAntialiased, USE_ANTIALIASING) l = make.legend("TR") if show_legend: plot.add_item( l ) self.myranges = [] for r in this_range: self.add_range_to_plot(plot, r)
def error( self, x, y, dx, dy, title="", color=None, linestyle=None, linewidth=None, errorbarwidth=None, errorbarcap=None, errorbarmode=None, errorbaralpha=None, marker=None, markersize=None, markerfacecolor=None, markeredgecolor=None, shade=None, curvestyle=None, baseline=None, xaxis="bottom", yaxis="left", ): """ Make an errorbar curve `plot item` (:py:class:`guiqwt.curve.ErrorBarCurveItem` object) * x: 1D NumPy array * y: 1D NumPy array * dx: None, or scalar, or 1D NumPy array * dy: None, or scalar, or 1D NumPy array * color: curve color name * linestyle: curve line style (MATLAB-like string or attribute name from the :py:class:`PyQt4.QtCore.Qt.PenStyle` enum (i.e. "SolidLine" "DashLine", "DotLine", "DashDotLine", "DashDotDotLine" or "NoPen") * linewidth: line width (pixels) * marker: marker shape (MATLAB-like string or attribute name from the :py:class:`PyQt4.Qwt5.QwtSymbol.Style` enum (i.e. "Cross", "Ellipse", "Star1", "XCross", "Rect", "Diamond", "UTriangle", "DTriangle", "RTriangle", "LTriangle", "Star2" or "NoSymbol") * markersize: marker size (pixels) * markerfacecolor: marker face color name * markeredgecolor: marker edge color name * shade: 0 <= float <= 1 (curve shade) * curvestyle: attribute name from the :py:class:`PyQt4.Qwt5.QwtPlotCurve.CurveStyle` enum (i.e. "Lines", "Sticks", "Steps", "Dots" or "NoCurve") * baseline (float: default=0.0): the baseline is needed for filling the curve with a brush or the Sticks drawing style. * xaxis, yaxis: X/Y axes bound to curve Example:: error(x, y, None, dy, marker='Ellipse', markerfacecolor='#ffffff') which is equivalent to (MATLAB-style support):: error(x, y, None, dy, marker='o', markerfacecolor='w') """ basename = _("Curve") curveparam = CurveParam(title=basename, icon="curve.png") errorbarparam = ErrorBarParam(title=_("Error bars"), icon="errorbar.png") if not title: global CURVE_COUNT CURVE_COUNT += 1 curveparam.label = make_title(basename, CURVE_COUNT) self.__set_param( curveparam, title, color, linestyle, linewidth, marker, markersize, markerfacecolor, markeredgecolor, shade, curvestyle, baseline, ) errorbarparam.color = curveparam.line.color if errorbarwidth is not None: errorbarparam.width = errorbarwidth if errorbarcap is not None: errorbarparam.cap = errorbarcap if errorbarmode is not None: errorbarparam.mode = errorbarmode if errorbaralpha is not None: errorbarparam.alpha = errorbaralpha return self.perror(x, y, dx, dy, curveparam, errorbarparam, xaxis, yaxis)
def error(self, x, y, dx, dy, title="", color=None, linestyle=None, linewidth=None, errorbarwidth=None, errorbarcap=None, errorbarmode=None, errorbaralpha=None, marker=None, markersize=None, markerfacecolor=None, markeredgecolor=None, shade=None, curvestyle=None, baseline=None, xaxis="bottom", yaxis="left"): """ Make an errorbar curve `plot item` (:py:class:`guiqwt.curve.ErrorBarCurveItem` object) * x: 1D NumPy array * y: 1D NumPy array * dx: None, or scalar, or 1D NumPy array * dy: None, or scalar, or 1D NumPy array * color: curve color name * linestyle: curve line style (MATLAB-like string or attribute name from the :py:class:`PyQt4.QtCore.Qt.PenStyle` enum (i.e. "SolidLine" "DashLine", "DotLine", "DashDotLine", "DashDotDotLine" or "NoPen") * linewidth: line width (pixels) * marker: marker shape (MATLAB-like string or attribute name from the :py:class:`PyQt4.Qwt5.QwtSymbol.Style` enum (i.e. "Cross", "Ellipse", "Star1", "XCross", "Rect", "Diamond", "UTriangle", "DTriangle", "RTriangle", "LTriangle", "Star2" or "NoSymbol") * markersize: marker size (pixels) * markerfacecolor: marker face color name * markeredgecolor: marker edge color name * shade: 0 <= float <= 1 (curve shade) * curvestyle: attribute name from the :py:class:`PyQt4.Qwt5.QwtPlotCurve.CurveStyle` enum (i.e. "Lines", "Sticks", "Steps", "Dots" or "NoCurve") * baseline (float: default=0.0): the baseline is needed for filling the curve with a brush or the Sticks drawing style. * xaxis, yaxis: X/Y axes bound to curve Example:: error(x, y, None, dy, marker='Ellipse', markerfacecolor='#ffffff') which is equivalent to (MATLAB-style support):: error(x, y, None, dy, marker='o', markerfacecolor='w') """ basename = _("Curve") curveparam = CurveParam(title=basename, icon='curve.png') errorbarparam = ErrorBarParam(title=_("Error bars"), icon='errorbar.png') if not title: global CURVE_COUNT CURVE_COUNT += 1 curveparam.label = make_title(basename, CURVE_COUNT) self.__set_param(curveparam, title, color, linestyle, linewidth, marker, markersize, markerfacecolor, markeredgecolor, shade, curvestyle, baseline) errorbarparam.color = curveparam.line.color if errorbarwidth is not None: errorbarparam.width = errorbarwidth if errorbarcap is not None: errorbarparam.cap = errorbarcap if errorbarmode is not None: errorbarparam.mode = errorbarmode if errorbaralpha is not None: errorbarparam.alpha = errorbaralpha return self.perror(x, y, dx, dy, curveparam, errorbarparam, xaxis, yaxis)