PlotWindow: Plot widget with toolbar

A PlotWidget with additional toolbars.

The PlotWindow is a subclass of PlotWidget.

PlotWindow class

class PlotWindow(parent=None, backend=None, resetzoom=True, autoScale=True, logScale=True, grid=True, curveStyle=True, colormap=True, aspectRatio=True, yInverted=True, copy=True, save=True, print_=True, control=False, position=False, roi=True, mask=True, fit=False)[source]

Bases: silx.gui.plot.PlotWidget.PlotWidget

Qt Widget providing a 1D/2D plot area and additional tools.

This widgets inherits from PlotWidget and provides its plot API.

Initialiser parameters:

Parameters
  • parent – The parent of this widget or None.

  • backend (str or BackendBase.BackendBase) – The backend to use for the plot (default: matplotlib). See PlotWidget for the list of supported backend.

  • resetzoom (bool) – Toggle visibility of reset zoom action.

  • autoScale (bool) – Toggle visibility of axes autoscale actions.

  • logScale (bool) – Toggle visibility of axes log scale actions.

  • grid (bool) – Toggle visibility of grid mode action.

  • curveStyle (bool) – Toggle visibility of curve style action.

  • colormap (bool) – Toggle visibility of colormap action.

  • aspectRatio (bool) – Toggle visibility of aspect ratio button.

  • yInverted (bool) – Toggle visibility of Y axis direction button.

  • copy (bool) – Toggle visibility of copy action.

  • save (bool) – Toggle visibility of save action.

  • print (bool) – Toggle visibility of print action.

  • control (bool) – True to display an Options button with a sub-menu to show legends, toggle crosshair and pan with arrows. (Default: False)

  • position – True to display widget with (x, y) mouse position (Default: False). It also supports a list of (name, funct(x, y)->value) to customize the displayed values. See PositionInfo.

  • roi (bool) – Toggle visibilty of ROI action.

  • mask (bool) – Toggle visibilty of mask action.

  • fit (bool) – Toggle visibilty of fit action.

setBackend(backend)[source]

Set the backend to use for rendering.

Supported backends:

  • ‘matplotlib’ and ‘mpl’: Matplotlib with Qt.

  • ‘opengl’ and ‘gl’: OpenGL backend (requires PyOpenGL and OpenGL >= 2.1)

  • ‘none’: No backend, to run headless for testing purpose.

Parameters

backend (Union[str,BackendBase,List[Union[str,BackendBase]]]) – The backend to use, in: ‘matplotlib’ (default), ‘mpl’, ‘opengl’, ‘gl’, ‘none’, a BackendBase.BackendBase class. If multiple backends are provided, the first available one is used.

Raises
  • ValueError – Unsupported backend descriptor

  • RuntimeError – Error while loading a backend

setBackgroundColor(color)[source]

Set the background color of this widget.

Parameters

color (Union[List[int],List[float],QColor]) – The new RGB(A) color.

setDataBackgroundColor(color)[source]

Set the background color of the plot area.

Set to None or an invalid QColor to use the background color.

Parameters

color (Union[List[int],List[float],QColor,None]) – The new RGB(A) color.

setForegroundColor(color)[source]

Set the foreground color of this widget.

Parameters

color (Union[List[int],List[float],QColor]) – The new RGB(A) color.

getInteractiveModeToolBar()[source]

Returns QToolBar controlling interactive mode.

Return type

QToolBar

getOutputToolBar()[source]

Returns QToolBar containing save, copy and print actions

Return type

QToolBar

getPositionInfoWidget()[source]

Returns the widget displaying current cursor position information

Return type

PositionInfo

getSelectionMask()[source]

Return the current mask handled by maskToolsDockWidget.

Returns

The array of the mask with dimension of the ‘active’ image. If there is no active image, an empty array is returned.

Return type

2D numpy.ndarray of uint8

setSelectionMask(mask)[source]

Set the mask handled by maskToolsDockWidget.

If the provided mask has not the same dimension as the ‘active’ image, it will by cropped or padded.

Parameters

mask (numpy.ndarray of uint8 of dimension 2, C-contiguous. Array of other types are converted.) – The array to use for the mask.

Returns

True if success, False if failed

toolBar()[source]

Return a QToolBar from the QAction of the PlotWindow.

menu(title='Plot', parent=None)[source]

Return a QMenu from the QAction of the PlotWindow.

Parameters
  • title (str) – The title of the QMenu

  • parent – See QMenu

addTabbedDockWidget(dock_widget)[source]

Add a dock widget as a new tab if there are already dock widgets in the plot. When the first tab is added, the area is chosen depending on the plot geometry: if the window is much wider than it is high, the right dock area is used, else the bottom dock area is used.

Parameters

dock_widget – Instance of QDockWidget to be added.

removeDockWidget(dockwidget)[source]

Removes the dockwidget from the main window layout and hides it.

Note that the dockwidget is not deleted.

Parameters

dockwidget (QDockWidget) –

getColorBarWidget()[source]

Returns the embedded ColorBarWidget widget.

Return type

ColorBarWidget

getLegendsDockWidget()[source]

DockWidget with Legend panel

getCurvesRoiWidget()[source]

Return the CurvesROIWidget.

silx.gui.plot.CurvesROIWidget.CurvesROIWidget offers a getter and a setter for the ROI data:

  • CurvesROIWidget.getRois()

  • CurvesROIWidget.setRois()

getMaskToolsDockWidget()[source]

DockWidget with image mask panel (lazy-loaded).

getStatsWidget()[source]

Returns a BasicStatsWidget connected to this plot

Return type

BasicStatsWidget

getConsoleAction()[source]

QAction handling the IPython console activation.

By default, it is connected to a method that initializes the console widget the first time the user clicks the “Console” menu button. The following clicks, after initialization is done, will toggle the visibility of the console widget.

Return type

QAction

getCrosshairAction()[source]

Action toggling crosshair cursor mode.

Return type

actions.PlotAction

getMaskAction()[source]

QAction toggling image mask dock widget

Return type

QAction

getPanWithArrowKeysAction()[source]

Action toggling pan with arrow keys.

Return type

actions.PlotAction

getRoiAction()[source]

QAction toggling curve ROI dock widget

Return type

QAction

getResetZoomAction()[source]

Action resetting the zoom

Return type

actions.PlotAction

getZoomInAction()[source]

Action to zoom in

Return type

actions.PlotAction

getZoomOutAction()[source]

Action to zoom out

Return type

actions.PlotAction

getXAxisAutoScaleAction()[source]

Action to toggle the X axis autoscale on zoom reset

Return type

actions.PlotAction

getYAxisAutoScaleAction()[source]

Action to toggle the Y axis autoscale on zoom reset

Return type

actions.PlotAction

getXAxisLogarithmicAction()[source]

Action to toggle logarithmic X axis

Return type

actions.PlotAction

getYAxisLogarithmicAction()[source]

Action to toggle logarithmic Y axis

Return type

actions.PlotAction

getGridAction()[source]

Action to toggle the grid visibility in the plot

Return type

actions.PlotAction

getCurveStyleAction()[source]

Action to change curve line and markers styles

Return type

actions.PlotAction

getColormapAction()[source]

Action open a colormap dialog to change active image and default colormap.

Return type

actions.PlotAction

getKeepDataAspectRatioButton()[source]

Button to toggle aspect ratio preservation

Return type

PlotToolButtons.AspectToolButton

getKeepDataAspectRatioAction()[source]

Action associated to keepDataAspectRatioButton. Use this to change the visibility of keepDataAspectRatioButton in the toolbar (See QToolBar.addWidget() documentation).

Return type

actions.PlotAction

getYAxisInvertedButton()[source]

Button to switch the Y axis orientation

Return type

PlotToolButtons.YAxisOriginToolButton

getYAxisInvertedAction()[source]

Action associated to yAxisInvertedButton. Use this to change the visibility yAxisInvertedButton in the toolbar. (See QToolBar.addWidget() documentation).

Return type

actions.PlotAction

getIntensityHistogramAction()[source]

Action toggling the histogram intensity Plot widget

Return type

actions.PlotAction

getCopyAction()[source]

Action to copy plot snapshot to clipboard

Return type

actions.PlotAction

getSaveAction()[source]

Action to save plot

Return type

actions.PlotAction

getPrintAction()[source]

Action to print plot

Return type

actions.PlotAction

getFitAction()[source]

Action to fit selected curve

Return type

actions.PlotAction

getMedianFilter1DAction()[source]

Action toggling the 1D median filter

Return type

actions.PlotAction

getMedianFilter2DAction()[source]

Action toggling the 2D median filter

Return type

actions.PlotAction

getColorBarAction()[source]

Action toggling the colorbar show/hide action

Warning

to show/hide the plot colorbar call directly the ColorBar widget using getColorBarWidget()

Return type

actions.PlotAction

Plot1D: Plot curves

class Plot1D(parent=None, backend=None)[source]

Bases: silx.gui.plot.PlotWindow.PlotWindow

PlotWindow with tools specific for curves.

This widgets provides the plot API of PlotWidget.

Parameters
  • parent – The parent of this widget

  • backend (str or BackendBase.BackendBase) – The backend to use for the plot (default: matplotlib). See PlotWidget for the list of supported backend.

Plot2D: Plot images

class Plot2D(parent=None, backend=None)[source]

Bases: silx.gui.plot.PlotWindow.PlotWindow

PlotWindow with a toolbar specific for images.

This widgets provides the plot API of :~:.PlotWidget.

Parameters
  • parent – The parent of this widget

  • backend (str or BackendBase.BackendBase) – The backend to use for the plot (default: matplotlib). See PlotWidget for the list of supported backend.

getProfileToolbar()[source]

Profile tools attached to this plot

See silx.gui.plot.Profile.ProfileToolBar

getProfilePlot()[source]

Return plot window used to display profile curve.

Returns

Plot1D