The PlotWidget is a Qt widget providing the plot API initially provided in PyMca. It is the basis of other plot widget, thus all plot widgets share the same API.
For an introduction and examples of the plot API, see Getting started with plot widgets.
This is a choosen subset of the complete plot API, the full API is documented in silx.gui.plot.Plot.
Bases: PyQt4.QtGui.QMainWindow, silx.gui.plot.Plot.Plot
Qt Widget providing a 1D/2D plot.
This widget is a QMainWindow. It provides Qt signals for the Plot and add supports for panning with arrow keys.
Parameters: |
|
---|
Those methods allow to add and update plotted data:
Add a 1D curve given by x an y to the graph.
Curves are uniquely identified by their legend. To add multiple curves, call addCurve() multiple times with different legend argument. To replace/update an existing curve, call addCurve() with the existing curve legend. If you wan’t to display the curve values as an histogram see the histogram parameter.
When curve parameters are not provided, if a curve with the same legend is displayed in the plot, its parameters are used.
Parameters: |
|
---|---|
Returns: | The key string identify this curve |
Add a 2D dataset or an image to the plot.
It displays either an array of data using a colormap or a RGB(A) image.
Images are uniquely identified by their legend. To add multiple images, call addImage() multiple times with different legend argument. To replace/update an existing image, call addImage() with the existing image legend.
When image parameters are not provided, if an image with the same legend is displayed in the plot, its parameters are used.
Parameters: |
|
---|---|
Returns: | The key string identify this image |
It is also possible to add point or line markers to the plot:
Add a point marker to the plot.
Markers are uniquely identified by their legend. As opposed to curves, images and items, two calls to addMarker() without legend argument adds two markers with different identifying legends.
Parameters: |
|
---|---|
Returns: | The key string identify this marker |
Add a vertical line marker to the plot.
Markers are uniquely identified by their legend. As opposed to curves, images and items, two calls to addXMarker() without legend argument adds two markers with different identifying legends.
Parameters: |
|
---|---|
Returns: | The key string identify this marker |
Add a horizontal line marker to the plot.
Markers are uniquely identified by their legend. As opposed to curves, images and items, two calls to addYMarker() without legend argument adds two markers with different identifying legends.
Parameters: |
|
---|---|
Returns: | The key string identify this marker |
Remove everything from the plot.
Remove one or all element(s) of the given legend and kind.
Examples:
Parameters: |
|
---|
Those methods handle the text labels of the axes and the plot title:
Return the plot main title as a str.
Set the plot main title.
Parameters: | title (str) – Main title of the plot (default: ‘’) |
---|
Return the current X axis label as a str.
Set the plot X axis label.
The provided label can be temporarily replaced by the X label of the active curve if any.
Parameters: | label (str) – The X axis label (default: ‘X’) |
---|
Return the current Y axis label as a str.
Parameters: | axis (str) – The Y axis for which to get the label (left or right) |
---|
Set the plot Y axis label.
The provided label can be temporarily replaced by the Y label of the active curve if any.
Parameters: |
|
---|
Those methods change the range of data values displayed on each axis.
Get the graph X (bottom) limits.
Returns: | Minimum and maximum values of the X axis |
---|
Set the graph X (bottom) limits.
Parameters: |
|
---|
Get the graph Y limits.
Parameters: | axis (str) – The axis for which to get the limits: Either ‘left’ or ‘right’ |
---|---|
Returns: | Minimum and maximum values of the X axis |
Set the graph Y limits.
Parameters: |
|
---|
Set the limits of the X and Y axes at once.
If y2min or y2max is None, the right Y axis limits are not updated.
Parameters: |
|
---|
The following methods handle the display properties of the axes:
Return True if X axis scale is logarithmic, False if linear.
Set the bottom X axis scale (either linear or logarithmic).
Parameters: | flag (bool) – True to use a logarithmic scale, False for linear. |
---|
Return True if Y axis scale is logarithmic, False if linear.
Set the Y axes scale (either linear or logarithmic).
Parameters: | flag (bool) – True to use a logarithmic scale, False for linear. |
---|
Return True if Y axis goes from top to bottom, False otherwise.
Set the Y axis orientation.
Parameters: | flag (bool) – True for Y axis going from top to bottom, False for Y axis going from bottom to top |
---|
Returns whether the plot is keeping data aspect ratio or not.
Set whether the plot keeps data aspect ratio or not.
Parameters: | flag (bool) – True to respect data aspect ratio |
---|
Return the current grid mode, either None, ‘major’ or ‘both’.
See setGraphGrid().
Set the type of grid to display.
Parameters: | which (str of bool) – None or False to disable the grid, ‘major’ or True for grid on major ticks (the default), ‘both’ for grid on both major and minor ticks. |
---|
Reset the plot limits to the bounds of the data and redraw the plot.
It automatically scale limits of axes that are in autoscale mode (See setXAxisAutoScale(), setYAxisAutoScale()). It keeps current limits on axes that are not in autoscale mode.
Extra margins can be added around the data inside the plot area. Margins are given as one ratio of the data range per limit of the data (xMin, xMax, yMin and yMax limits). For log scale, extra margins are applied in log10 of the data.
Parameters: | dataMargins (A 4-tuple of float as (xMin, xMax, yMin, yMax).) – Ratios of margins to add around the data inside the plot area for each side (Default: no margins). |
---|
Those methods change the behavior of PlotWidget.resetZoom().
Get the default data margin ratios, see setDataMargins().
Returns: | The margin ratios for each side (xMin, xMax, yMin, yMax). |
---|---|
Return type: | A 4-tuple of floats. |
Set the default data margins to use in resetZoom().
Set the default ratios of margins (as floats) to add around the data inside the plot area for each side.
Return True if X axis is automatically adjusting its limits.
Set the X axis limits adjusting behavior of resetZoom().
Parameters: | flag (bool) – True to resize limits automatically, False to disable it. |
---|
Return True if Y axes are automatically adjusting its limits.
Set the Y axis limits adjusting behavior of resetZoom().
Parameters: | flag (bool) – True to resize limits automatically, False to disable it. |
---|
Those methods set-up default values for PlotWidget.addCurve() and PlotWidget.addImage():
Return the default colormap used by addImage() as a dict.
See Plot for the documentation of the colormap dict.
Set the default colormap used by addImage().
Setting the default colormap do not change any currently displayed image. It only affects future calls to addImage() without the colormap parameter.
Parameters: | colormap (dict) – The description of the default colormap, or None to set the colormap to a linear autoscale gray colormap. See Plot for the documentation of the colormap dict. |
---|
Get the supported colormap names as a tuple of str.
The list should at least contain and start by: (‘gray’, ‘reversed gray’, ‘temperature’, ‘red’, ‘green’, ‘blue’)
Set the default symbol of all curves.
When called, this reset the symbol of all existing curves.
Parameters: | flag (bool) – True to use ‘o’ as the default curve symbol, False to use no symbol. |
---|
Toggle the use of lines as the default curve line style.
Parameters: | flag (bool) – True to use a line as the default line style, False to use no line as the default line style. |
---|
Those methods allow to change the interaction mode (e.g., drawing mode) of the plot and to toggle the use of a crosshair cursor:
Returns the current interactive mode as a dict.
The returned dict contains at least the key ‘mode’. Mode can be: ‘draw’, ‘pan’, ‘select’, ‘zoom’. It can also contains extra keys (e.g., ‘color’) specific to a mode as provided to setInteractiveMode().
Switch the interactive mode.
Parameters: |
|
---|
Returns the state of the crosshair cursor.
See setGraphCursor().
Returns: | None if the crosshair cursor is not active, else a tuple (color, linewidth, linestyle). |
---|
Toggle the display of a crosshair cursor and set its attributes.
Parameters: |
|
---|
Save a snapshot of the plot.
Supported file formats: “png”, “svg”, “pdf”, “ps”, “eps”, “tif”, “tiff”, “jpeg”, “jpg”.
Parameters: |
|
---|---|
Returns: | False if cannot save the plot, True otherwise |
The PlotWidget provides the following Qt signals:
Signal for all events of the plot.
The signal information is provided as a dict. See Plot for documentation of the content of the dict.
Signal emitted when Y axis orientation has changed
Signal emitted when X axis scale has changed
Signal emitted when Y axis scale has changed
Signal emitted when X axis autoscale has changed
Signal emitted when Y axis autoscale has changed
Signal emitted when plot keep aspect ratio has changed
Signal emitted when plot grid has changed
Signal emitted when plot crosshair cursor has changed
Signal emitted when pan with arrow keys has changed
Signal emitted when the content of the plot is changed.
It provides 3 informations:
Signal emitted when the active curve has changed.
It provides 2 informations:
Signal emitted when the active image has changed.
It provides 2 informations:
Signal emitted when the interactive mode has changed
It provides the source as passed to setInteractiveMode().