Bases: PyQt4.Qwt5.Qwt.QwtPlot, taurus.qt.qtgui.base.taurusbase.TaurusBaseWidget
TaurusPlot is a general widget for plotting 1D data sets. It is an extended taurus-aware version of QwtPlot.
TaurusPlot already incorporates by default many features that can be added to a regular QwtPlot:
- Zoomming, panning, and magnifier are enabled by default
- Autoscaling is enabled and associated to the ESC key
- Methods are available to add new curves which can either be associated to taurus attributes or be “raw data” (i.e., values that are not directly aware of control system events)
- Context menu offers access to many options
- A plot configuration dialog, and save/restore configuration facilities
- Date-time scales and linear/log scales support
- Methods for importing/exporting curves from/to ASCII data
- Methods for printing and exporting the plot to PDF
- Methods for creating curves from arbitrary functions
- Data inspection facilities
- ...
For an overview of the features from an user point of view, see the TaurusPlot User’s Interface Guide.
You can also see some code that exemplifies the use of TaurusPlot in the TaurusPlot coding examples
Important: although TaurusPlot subclasses QwtPlot and therefore it is possible to use QwtPlot’s lower level methods for attaching QwtPlotItems (such as QwtPlotCurves) to the plot, it is highly recommended to use the higher-level methods provided by TaurusPlot to interact with the datasets attached to a TaurusPlot (e.g., addModels(), attachRawData()). This is because TaurusPlot keeps records of the items attached via its own methods.
Adds models to the existing ones:
Parameters: | modelNames (:class:~`sequence` <:class:~`str`>) – the names of the models to be added to the plot. |
---|
See also
setModels(), removeModels()
Whether the Zoomers are enabled for this plot
Return type: | :class:~`bool` |
---|---|
Returns: |
See also
sets the axes according to settings stored in the axes dict, which can be generated with _createAxesDict()
Parameters: | axes (:class:~`dict`) – contains axes properties |
---|
implemented as in TaurusBaseComponent.applyConfig()
Parameters: | configdict (:class:~`dict` <:class:~`str`, :class:~`object`>) – |
---|
See also
createConfig(), TaurusBaseComponent.applyConfig()
sets the configurations according to settings stored in the misc dict, which can be generated with _createMiscDict()
Parameters: | miscdict (:class:~`dict`) – Dictionary of properties |
---|
attaches a curve to the plot formed from raw data that comes in a dict
Parameters: |
|
---|---|
Return type: | :class:~`QwtPlotCurve` |
Returns: | the attached curve |
Note: every member of the rawdata dictionary is optional except for the y values (or, alternatively, f(x) AND x)
Note: using “name” in the rawdata dictionary is a still-supported-but-deprecated synonim of “title”.
Optimized autoscale of whole plot
shows/hides Y1 and Y2 depending of whether there are curves associated to them. Also takes care of changing the zoomer if needed
Shows a dialog to set the curves titles (it will change the current curves titles and the default curves titles)
Parameters: | curveNamesList (:class:~`sequence` <:class:~`str`> or :class:~`iterator` <:class:~`str`>) – names of the curves to which the title will be changed (if None given , it will apply to all the curves except the raw data ones and it will also be used as default for newly created ones) |
---|---|
Return type: | :class:~`caselessDict` <:class:~`str`, :class:~`str`> |
Returns: | dictionary with key=curvename and value=newtitle |
See also
Check if the version of configdict is supported.
Parameters: |
|
---|---|
Return type: | :class:~`bool` |
Returns: | returns True if the configdict is of the right version |
See also
TaurusBaseComponent.checkConfigVersion()
removes all rawdata curves from the plot.
Return type: | :class:~`list` <:class:~`str`> |
---|---|
Returns: | the list of removed curve names |
See Qwidget.closeEvent()
This function is called when there is context menu event. See Qwidget.closeEvent() A pop up menu will be shown with the available options. Different parts of the plot (canvas, axes,...) behave differently
Returns a pickable dictionary containing all relevant information about the current plot. Implemented as in TaurusBaseComponent.createConfig() For Tango attributes it stores the attribute name and the curve properties For raw data curves, it stores the data as well.
Hint: The following code allows you to serialize the configuration dictionary as a string (which you can store as a QSetting, or as a Tango Attribute):
import pickle
c = pickle.dumps(taurusplot.createConfig()) #c is a string that can be stored
Parameters: | curvenames (:class:~`sequence` <:class:~`str`>) – a sequence of curve names for which the configuration will be stored (all by default). |
---|---|
Return type: | :class:~`dict` |
Returns: | configurations (which can be loaded with applyConfig) |
See also
createConfig(), TaurusBaseComponent.createConfig()
slot that is called whenever a curve emits a dataChanged signal
Emits : | “dataChanged(const QString &)” |
---|---|
Parameters: | name (:class:~`str`) – curve name |
See setDefaultCurvesTitle
dettaches a raw data curve
Parameters: | name (:class:~`str`) – name (identifier) of the curve to dettach |
---|
reimplemented to support dropping of modelnames in taurusplots
Whether the magnifier is enabled for this plot
Return type: | :class:~`bool` |
---|---|
Returns: |
See also
Whether painting optimization is enabled for this plot
Return type: | :class:~`bool` |
---|---|
Returns: |
Whether the Panner is enabled for this plot
Return type: | :class:~`bool` |
---|---|
Returns: |
See also
Opens a dialog for exporting curves to ASCII files.
Parameters: | curves (:class:~`sequence` <:class:~`str`>) – the curves curves that will be exportable. if None given, all curves are offered for export. |
---|
Export the plot to a PDF. slot for the _exportPdfAction.
Parameters: | fileName (:class:~`str`) – The name of the file to which the plot will be exported. If None given, the user will be prompted for a file name. |
---|
Launches a QPrintDialog for printing the plot
Whether the Zoomers are enabled for this plot
Return type: | :class:~`bool` |
---|---|
Returns: |
See also
Returns the label format for the given axis
Parameters: | axis (:class:~`Qwt5.QwtPlot.Axis`) – the axis |
---|---|
Return type: | :class:~`str` or :class:~`None` |
Returns: |
See also
If set, it returns the axis title text, otherwise returns the default axis name
Parameters: | axis (:class:~`Qwt.QwtPlot.Axis`) – |
---|---|
Return type: | :class:~`unicode` |
Returns: |
returns the lower and higher bounds for the given axis, or None,None if the axis is in autoscale mode
Parameters: | axis (:class:~`Qwt5.QwtPlot.Axis`) – the axis |
---|---|
Return type: | :class:~`float,float` |
Returns: | atuple of floats (or None,None) |
gets a curve object by name.
Important: Note that the curve object is not thread safe. Therefore, if you access to the curve object you must do it protected by the TaurusPlot.curves_lock reentrant lock.
Parameters: | name (:class:~`str`) – the curve name |
---|---|
Return type: | :class:~`TaurusCurve` |
Returns: | the curve object corresponding to name |
Returns the appearance properties of all curves in the plot.
Return type: | :class:~`dict` <:class:~`str`, :class:~`CurveAppearanceProperties`> |
---|---|
Returns: | a dictionary whose keys are the curve names and whose values are the corresponding CurveAppearanceProperties object |
See also
returns the data in the curve as two lists (x,y) of values
Parameters: |
|
---|---|
Return type: | :class:~`tuple` <:class:~`list`, :class:~`list`> |
Returns: | tuple of two lists (x,y) containing the curve data |
returns the names of all TaurusCurves attached to the plot (in arbitrary order, if you need a sorted list, see getCurveNamesSorted()).
Return type: | :class:~`list` <:class:~`str`> |
---|---|
Returns: | a copy of self.curves.keys() |
See also
returns the names of the curves in z order (which is the one used in the legend, and in showing the curves).
Return type: | :class:~`list` <:class:~`str`> |
---|---|
Returns: | curve names |
See also
Shows a dialog containing descriptive statistics on curves
Parameters: |
|
---|---|
Return type: | :class:~`dict` |
Returns: | Returns a dictionary whose keys are the curve names and whose values are the dictionaries returned by TaurusCurve.getStats() |
return the current title associated to a given curve name
Parameters: | curvename (:class:~`str`) – the name of the curve |
---|---|
Return type: | :class:~`str` |
Returns: |
return a “smart” alignment for the axis labels depending on the axis and the label rotation
Parameters: |
|
---|---|
Return type: | :class:~`Qt.Alignment` |
Returns: | an alignment |
See setDefaultCurvesTitle
returns the grid of the plot
Return type: | :class:~`Qwt5.QwtPlotGrid` |
---|---|
Returns: |
Returns the color of the plot grid
Return type: | :class:~`Qt.QColor` |
---|---|
Returns: |
Returns the width of the grid lines
Return type: | :class:~`int` |
---|---|
Returns: | with of the gridlines (in pixels) |
Returns the legend object of this plot
Return type: | :class:~`QwtLegend` |
---|---|
Returns: |
returns the current legend position
Return type: | :class:~`Qwt5.QwtPlot.LegendPosition` |
---|---|
Returns: |
returns the list of model names.
Return type: | :class:~`CaselessList` <:class:~`str`> |
---|---|
Returns: |
See also
See TaurusBaseComponent.getModelObj()
See TaurusBaseComponent.getParentTaurusComponent()
returns the marker for the picked points for this plot
Return type: | :class:~`TaurusCurveMarker` |
---|---|
Returns: |
deprecated method . Only here for backwards compatibility. It will be removed, eventually. Now you should use the TaurusPlot instance instead of TaurusPlot.getPlot()
Returns pertinent information in order to be able to build a valid QtDesigner widget plugin
Return type: | :class:~`dict` |
---|---|
Returns: | a map with pertinent designer information |
See: TaurusBaseComponent.getParentModel()
same as self.axisScaleDiv(axis).range()
Parameters: | axis (:class:~`Qwt5.QwtPlot.Axis`) – the (X) axis. (default=Qwt5.QwtPlot.xBottom) |
---|---|
Return type: | :class:~`float` |
Returns: | the absolute difference between the higher and lower limits of the axis scale |
Whether the current X scale is in Dynamic scaling mode
Return type: | :class:~`bool` |
---|---|
Returns: |
See also
setXDynScale(), meth:isXDynScaleSupported
Returns whether the X axis is in “Time mode”
Return type: | :class:~`bool` |
---|---|
Returns: | True means the X axis is in Time mode, False |
See also
returns a list of the zoomer(s) associated to the given axis. If None is passed, it returns a list containing the current zoomer
Parameters: | axis (:class:~`Qwt5.QwtPlot.Axis`) – the axis |
---|
Returns the color of the plot grid
Return type: | :class:~`Qt.QColor` |
---|---|
Returns: |
Returns the width of the grid lines
Return type: | :class:~`int` |
---|---|
Returns: | with of the gridlines (in pixels) |
imports curves from ASCII files. It uses :meth:numpy.loadtxt The data in the file(s) must be formatted in columns, with possibly a header and/or commented lines. Each column in a file will be imported as an independent RawData curve (except for the column whose index is passed in xcol)
Parameters: |
|
---|
See also
numpy.loadtxt()
Whether the magnifier is enabled for this plot
Return type: | :class:~`bool` |
---|---|
Returns: |
See also
Whether painting optimization is enabled for this plot
Return type: | :class:~`bool` |
---|---|
Returns: |
Whether the Panner is enabled for this plot
Return type: | :class:~`bool` |
---|---|
Returns: |
See also
Returns the pause state
Return type: | :class:~`bool` |
---|---|
Returns: |
Whether this widget offers xDynScale-related options. Useful for showing-hiding them in menus and dialogs
Return type: | :class:~`bool` |
---|---|
Returns: |
See also
returns the current legend position
Return type: | :class:~`Qwt5.QwtPlot.LegendPosition` |
---|---|
Returns: |
Reads a file stored by saveConfig() and applies the settings
Parameters: | ifile (:class:~`file` or :class:~`string`) – file or filename from where to read the configuration |
---|---|
Return type: | :class:~`str` |
Returns: | file name used |
See QWidget.minimumSizeHint()
returns the list of model names.
Return type: | :class:~`CaselessList` <:class:~`str`> |
---|---|
Returns: |
See also
Applies the properties given in prop to all the curves named in names. This functions is called from the config dialog when changes are applied.
Parameters: |
|
---|
slot for the curveStatsAction. Allows the user to select a range and then shows curve statistics on that range.
See TaurusBaseComponent.parentModelChanged()
Finds the pyxel-wise closest data point to the given position. The valid search space is constrained by the scope and targetCurveNames parameters.
Parameters: |
|
---|---|
Return type: | :class:~`tuple` <:class:~`Qt.QPointF`, :class:~`str`, :class:~`int`> or :class:~`tuple` <:class:~`None`, :class:~`None`, :class:~`None`> |
Returns: | if a point was picked within the scope, it returns a tuple containing the picked point (as a Qt.QPointF), the curve name and the index of the picked point in the curve data. If no point was found within the scope, it returns None,None,None |
helper slot. Calls self.importAscii(xcol=xcol, skiprows=skiprows ) See meth:importAscii
Removes models from those already in the plot.
Parameters: | modelNames (:class:~`sequence` <:class:~`str`>) – the names of the models to be added to the plot. |
---|
See also
setModels(), addModels()
same as setAllowZoomers(True)
equivalent to setAxisLabelFormat(axis, None)
Parameters: | axis (:class:~`Qwt5.QwtPlot.Axis`) – the axis |
---|
See also:setAxisLabelFormat
resets the defaultCurvesTitle property to ‘<label>’
See also
equivalent to self.setGridColor(Qt.Qt.gray)
equivalent to self.setGridWidth(1)
equivalent to setLegendPosition(Qwt5.QwtPlot.RightLegend)
same as setMagnifierEnabled(True)
equivalent to setModel([])
Equivalent to setOptimizationEnabled(True)
same as setPannerEnabled(True)
equivalent to setUseParentModel(False)
equivalent to setXIsTime(False)
Stores the current curves and their display properties in a file for later retrieval.
Parameters: |
|
---|---|
Return type: | :class:~`str` |
Returns: | file name used |
Changes the input mode to allow the user to select a region of the X axis
Parameters: |
|
---|
enable/disable the zoomers for the plot. (The zoomers provide zooming by selecting a region of the plot)
Parameters: | allow (:class:~`bool`) – If True, zoomers are enabled, otherwise, they are disabled |
---|
Convenience method for setting the format of any or all axes if format=None, specific formats for x, y1 and y2 can be explicitly set, e.g:
setAxesLabelFormat("%6.2f") #<--sets the "%6.2f" format for all axes
setAxesLabelFormat(xformat=None, y1format="%i") #<--sets the default format for x and an integer format fotr y1
Parameters: |
|
---|
See also
Sets the axis to autoscale and resets the zoomer for that axis if needed
Parameters: | axis (:class:~`Qwt5.QwtPlot.Axis`) – the axis |
---|
See also
By calling this method, the scale vaues can be substituted by custom labels at arbitrary positions. In general, it is a good idea to let the alignment to be autocalculated.
Parameters: |
|
---|
changes the format of an axis label. format is a python format string (e.g., “%6.2f”), . If format=None, the default behaviour is set (which uses QLocale.system().toString(value))
Parameters: |
|
---|
Rescales the given axis to the range defined by min and max. If min and max are None, autoscales. It also takes care of resetting the affected zoomer(s)
Parameters: |
|
---|
Example:
tt=TaurusTrend()
tt.setAxisScale(tt.yLeft, 0, 10) #this will set the Y1 axis range from 0 to 10
tt.setAxisScale(tt.xBottom, None, None) #This will autoscale the X axis
sets the type of scale, (log or linear) for a given axis, If scale is None, the scale type will be toggled
Parameters: |
|
---|
It gets a dictionary of namecurvenames,properties and applies the properties to the corresponding curves.
Parameters: | propDict (:class:~`dict` <:class:~`str`, :class:~`CurveAppearanceProperties`>) – a dictionary whose keys are the curve names and whose values are the corresponding CurveAppearanceProperties object |
---|
See also
Changes the titles of current curves.
Parameters: |
|
---|---|
Return type: | :class:~`caselessDict` <:class:~`str`, :class:~`str`> |
Returns: | dictionary with key=curvename and value=newtitle |
Change the Y axis of the given curves to the given axis.
Parameters: |
|
---|
sets the default title to be used for curves attached to this plot (the title is used, for example in the legend). Note that this does not affect to already existing curves. If you want that, see setCurvesTitle.
Parameters: | titletext (:class:~`str`) – the default text to be used for the titles of curves. It may contain any of the placeholders described in TaurusCurve.setTitleText |
---|
See also
propagates a list of taurus filters to the curves given by curvenames. See TaurusBaseComponent.setEventFilters()
Changes the color of the plot grid and refreshes the plot
Parameters: | color (:class:~`Qt.QColor`) – the new color for the grid |
---|
Changes the width of the plot grid lines and refreshes the plot
Parameters: | width (:class:~`int`) – with in pixels for the grid lines |
---|
Specify the position of the legend relative to the plot
Parameters: | pos (:class:~`Qwt5.QwtPlot.LegendPosition`) – |
---|
See also
Qwt5.QwtPlot.LegendPosition()
Specify whether the plot can be magnified (i.e. zoomed in and out with the mousewheel)
Parameters: | enable (:class:~`bool`) – If True, magnifying is enabled, otherwise, it is disabled |
---|
sets the models of the Tango attributes that should be displayed in this TaurusPlot.
Parameters: | modelNames (:class:~`sequence` <:class:~`str`> or :class:~`str`) – the names of the models to be plotted. For convenience, strings are also accepted (instead of a sequence of strings), in which case the string will be internally converted to a sequence by splitting it on whitespace. |
---|
See also
Specify whether the plot should use paint optimizations
Parameters: | enable (:class:~`bool`) – If True, optimization is enabled, otherwise, it is disabled |
---|
Specify whether the plot can be panned (i.e., dragged around to navigate it)
Parameters: | enable (:class:~`bool`) – If True, panning is enabled, otherwise, it is disabled |
---|
delegates the pausing to the curves
Parameters: | paused (:class:~`bool`) – if True, the plot will be paused |
---|
Sets whether the TaurusCurves of this plot should use the plot’s parent model
Parameters: | yesno (:class:~`bool`) – if True, the curves in the plot will use the Plot’s parent model |
---|
See also
TaurusBaseComponent.setParentModel()
it enables/disables the Dynamic scaling feature (also known as Fixed-range X scale, or “auto-scroll mode”). The Dynamic scaling consists in ensuring that:
Parameters: | enabled (:class:~`bool`) – if True, the Dynamic scaling is enabled for the X axis. Otherwise it is disabled. (Default=True) |
---|
See also
Whether this widget should offer xDynScale-related options in menus and dialogs.
Parameters: | supported (:class:~`bool`) – if True, the options related to xDynScale will be shown |
---|
See also
Specifies whether we the plot is in Time or in normal mode (i.e, whether the abscissas should be interpreted as unix epoch values or not)
Parameters: |
|
---|
See also
Slot for the showConfigMenuAction. Launches the plot configuration dialog.
switch visibility of a curve (as well as any markers associated to it) on/off
Important: This is a non-thread safe method. Do not manipulate curve objects without protecting the access with Taurusplot.curves_lock
Parameters: |
|
---|
Launches the data import dialog. This dialog lets the user manage which attributes are attached to the plot (using TaurusModelChooser) and also to generate raw data or import it from files
whether to show or not the legend.
Parameters: |
|
---|
This function will set the showMaxPeak flag of all the curves in the plot.
Parameters: | show (:class:~`bool`) – if True, the max values of the displayed curve(s) will be shown on the plot. Otherwise, they will be hidden. |
---|
This function will set the showMinPeak flag of all the curves in the plot.
Parameters: | show (:class:~`bool`) – if True, the min values of the displayed curve(s) will be shown on the plot. Otherwise, they will be hidden. |
---|
See QWidget.sizeHint()
Sorts the attached curves in a given z order. This affects both the ordering in the legend and the visibility order when curves overlap in the plotting area. The order is governed by the ordered parameter (or alphabetically if no parameter is passed).
Parameters: | ordered (:class:~`list` <:class:~`str`> or :class:~`None`) – A list of curve names in the desired order. If None passed, the items will be ordered alphabetically according to their title. |
---|
cycles through 3 possible states for a curve:
- invisible
- attached to Y1
- attached to Y2
Parameters: | curve (:class:~`TaurusCurve`) – the curve object |
---|
Enables/Disables the Inspector Mode. When “Inspector Mode” is enabled, the zoomer is disabled and clicking on the canvas triggers a search of a nearby data point using pickDataPoint (the cursor changes to indicate the mode).
Parameters: | enable (:class:~`bool` or :class:~`None`) – If True, it enables the Inspector Mode. If False, it disables it. If None passed, it toggles the mode. |
---|---|
Return type: | :class:~`bool` |
Returns: | whether the inspector mode has been enabled (True) or disabled (False) |
changes the current zoomer to that associated to the given axis (zoomer1 is attached to Y1 and zoomer2 to Y2). If no axis is passed, the zoomers are toggled.
Parameters: | axis (:class:~`Qwt.QwtPlot.Axis` or :class:~`None`) – axis to activate for zooming. If None passed, the zoomers are toggled. |
---|---|
Return type: | :class:~`Qwt.QwtPlot.Axis` |
Returns: | the Y axis of the enabled zoomer |
Updates the TaurusCurves being plotted. It adds a new curve for each new curve model passed and removes curves if they are not in the names.
Parameters: | names (:class:~`sequence` <:class:~`str`>) – a sequence of curve models. One curve will be created for each element of names. Each curve model can consist of a single attribute name (which will be used for the Y values) or by two attribute names separated by a ‘|’ (in which case, the left-hand attribute is used for the X values and the right hand value for the Y values) |
---|
Updates the legend object of the plot (if it does not exist, it may create a fresh one)
Parameters: | force (:class:~`bool`) – if True, the legend will be updated even if it is not being shown. (default=False) |
---|
See: TaurusBaseComponent.getParentModel()
Returns whether the X axis is in “Time mode”
Return type: | :class:~`bool` |
---|---|
Returns: | True means the X axis is in Time mode, False |
See also