Exemplo n.º 1
0
    def __init__(self, parent=None):
        super(CrossSectionPlot, self).__init__(parent=parent,
                                               title="",
                                               section="cross_section")
        self.perimage_mode = True
        self.autoscale_mode = True
        self.autorefresh_mode = True
        self.apply_lut = False
        self.single_source = False

        self.last_obj = None
        self.known_items = {}
        self._shapes = {}

        self.curveparam = CurveParam(_("Curve"), icon="curve.png")
        self.set_curve_style("cross_section", "curve")

        if self._height is not None:
            self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Minimum)
        elif self._width is not None:
            self.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Expanding)

        self.label = make.label(self.LABEL_TEXT, "C", (0, 0), "C")
        self.label.set_readonly(True)
        self.add_item(self.label)

        self.setAxisMaxMajor(self.Z_AXIS, self.Z_MAX_MAJOR)
        self.setAxisMaxMinor(self.Z_AXIS, 0)
Exemplo n.º 2
0
    def __init__(self, parent=None):
        super(LevelsHistogram, self).__init__(parent=parent,
                                              title="",
                                              section="histogram")
        self.antialiased = False

        # a dict of dict : plot -> selected items -> HistogramItem
        self._tracked_items = {}
        self.curveparam = CurveParam(_("Curve"), icon="curve.png")
        self.curveparam.read_config(CONF, "histogram", "curve")

        self.histparam = HistogramParam(_("Histogram"), icon="histogram.png")
        self.histparam.logscale = False
        self.histparam.n_bins = 256

        self.range = XRangeSelection(0, 1)
        self.range_mono_color = self.range.shapeparam.sel_line.color
        self.range_multi_color = CONF.get("histogram", "range/multi/color",
                                          "red")

        self.add_item(self.range, z=5)
        self.SIG_RANGE_CHANGED.connect(self.range_changed)
        self.set_active_item(self.range)

        self.setMinimumHeight(80)
        self.setAxisMaxMajor(self.Y_LEFT, 5)
        self.setAxisMaxMinor(self.Y_LEFT, 0)

        if parent is None:
            self.set_axis_title("bottom", "Levels")
Exemplo n.º 3
0
    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)
Exemplo n.º 4
0
    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)
Exemplo n.º 5
0
 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
Exemplo n.º 6
0
 def __init__(self, measurement=None):
     """\arg measurement a Measurement object storing data and scanning
     parameter.
     """
     self.__baseclass__ = ThothCurveItem
     self.measurement = Measurement()
     param = CurveParam(_("Line"), icon='curve.png')
     param.line.style = "SolidLine"
     param.line.width = 2.0
     CurveItem.__init__(self, param)
     if measurement is not None:
         self.set_measurement(measurement)
Exemplo n.º 7
0
 def __init__(self, taurusparam=None, curveparam=None, axesparam=None):
     if taurusparam is None:
         taurusparam = TaurusCurveParam()
     self.taurusparam = taurusparam
     if curveparam is None:
         curveparam = CurveParam()
         style = make.style.next()  # cycle through colors and linestyles
         update_style_attr(style, curveparam)
         curveparam.line.width = 2
     self.curveparam = curveparam
     self.axesparam = axesparam
     self.x = Component(taurusparam.xModel)
     self.y = Component(taurusparam.yModel)
     if not self.curveparam.label:
         self.curveparam.label = taurusparam.xModel
Exemplo n.º 8
0
 def __init__(self, curveparam=None, histparam=None):
     self.hist_count = None
     self.hist_bins = None
     self.bins = None
     self.old_bins = None
     self.source = None
     self.logscale = None
     self.old_logscale = None
     if curveparam is None:
         curveparam = CurveParam(_("Curve"), icon="curve.png")
         curveparam.curvestyle = "Steps"
     if histparam is None:
         self.histparam = HistogramParam(title=_("Histogram"), icon="histogram.png")
     else:
         self.histparam = histparam
     CurveItem.__init__(self, curveparam)
     self.setCurveAttribute(QwtPlotCurve.Inverted)
Exemplo n.º 9
0
    def curve(self, x, y, title="", color=None, linestyle=None, linewidth=None,
              marker=None, markersize=None, markerfacecolor=None,
              markeredgecolor=None, shade=None, curvestyle=None, baseline=None,
              xaxis="bottom", yaxis="left"):
        """
        Make a curve `plot item` from x, y, data
        (:py:class:`guiqwt.curve.CurveItem` object)

            * x: 1D NumPy array
            * y: 1D NumPy array
            * color: curve color name
            * linestyle: curve line style (MATLAB-like string or "SolidLine",
              "DashLine", "DotLine", "DashDotLine", "DashDotDotLine", "NoPen")
            * linewidth: line width (pixels)
            * marker: marker shape (MATLAB-like string or "Cross",
              "Ellipse", "Star1", "XCross", "Rect", "Diamond", "UTriangle", 
              "DTriangle", "RTriangle", "LTriangle", "Star2", "NoSymbol")
            * markersize: marker size (pixels)
            * markerfacecolor: marker face color name
            * markeredgecolor: marker edge color name
            * shade: 0 <= float <= 1 (curve shade)
            * curvestyle: "Lines", "Sticks", "Steps", "Dots", "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::
            
            curve(x, y, marker='Ellipse', markerfacecolor='#ffffff')

        which is equivalent to (MATLAB-style support)::

            curve(x, y, marker='o', markerfacecolor='w')
        """
        basename = _("Curve")
        param = CurveParam(title=basename, icon='curve.png')
        if not title:
            global CURVE_COUNT
            CURVE_COUNT += 1
            title = make_title(basename, CURVE_COUNT)
        self.__set_param(param, title, color, linestyle, linewidth, marker,
                         markersize, markerfacecolor, markeredgecolor, shade,
                         curvestyle, baseline)
        return self.pcurve(x, y, param, xaxis, yaxis)
Exemplo n.º 10
0
 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)
Exemplo n.º 11
0
    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)
Exemplo n.º 12
0
    def __init__(self,
                 parent,
                 name='Panel',
                 plots=[[['Cold', 1], ['Hot', 1]],
                        [['Antenna', 2], ['Reference', 1]]]):
        QSplitter.__init__(self, parent)
        self.parent = parent
        self.name = name
        self.plots = [i[0] for o in plots
                      for i in o]  # make the name's list flat

        self.active = None
        self.evnt = None

        self.xylim = self.XYlim()

        # Curve panels (plots)
        Hsplit = QSplitter(self)
        plotColumns = [QSplitter(self) for n in plots]

        for rows, c in zip(plots, plotColumns):
            c.setOrientation(Qt.Vertical)
            c.setChildrenCollapsible(False)

            c.cwidgets = [
                self.cplot(c,
                           xlabel=u"\u0394f [MHz]",
                           ylabel="Count",
                           updateWidgets=self.xylim.updateWidgets)
                for i in rows
            ]
            c.plots = [[CurveItem(CurveParam()) for j in range(i[1])]
                       for i in rows]

            for m, cw in enumerate(c.cwidgets):
                cw.set_title(rows[m][0])
                for p in c.plots[m]:
                    p.set_data([0], [0])
                    p.parent = cw
                    cw.add_item(p)
#				cw.set_axis_limits(BasePlot.Y_LEFT,0,1)
#				cw.set_axis_limits(BasePlot.X_BOTTOM,-750,750)
                cw.setDefaultAxis([-750, 750, 0, 1])
                c.addWidget(cw)

            Hsplit.addWidget(c)

        self.addWidget(Hsplit)
        self.addWidget(self.xylim)
        self.setOrientation(Qt.Vertical)

        self.curvePanels = dict(
            zip(self.plots, sum([c.cwidgets for c in plotColumns], [])))
        self.curves = dict(
            zip(self.plots, [i for o in plotColumns for i in o.plots]))

        for nm in self.plots:
            for p in self.curves[nm]:
                p.setPen(QPen(Qt.blue, 1))

        plotColumns[0].cwidgets[0].setActive()