PlotWindow
A PlotWidget with additionnal toolbars.
The PlotWindow is a subclass of PlotWidget.
It provides the plot API fully defined in Plot.
-
class silx.gui.plot.PlotWindow.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)[source]
Bases: silx.gui.plot.PlotWidget.PlotWidget
Qt Widget providing a 1D/2D plot area and additional tools.
This widget includes the following QAction as attributes:
- resetZoomAction: Reset zoom
- xAxisAutoScaleAction: Toggle X axis autoscale
- yAxisAutoScaleAction: Toggle Y axis autoscale
- xAxisLogarithmicAction: Toggle X axis log scale
- yAxisLogarithmicAction: Toggle Y axis log scale
- gridAction: Toggle plot grid
- curveStyleAction: Change curve line and markers style
- colormapAction: Open a colormap dialog to change active image
and default colormap.
- keepDataAspectRatioAction: Toggle keep aspect ratio
- yAxisInvertedAction: Toggle Y Axis direction
- copyAction: Copy plot snapshot to clipboard
- saveAction: Save plot
- printAction: Print plot
Initialiser parameters:
Parameters: |
- parent – The parent of this widget or None.
- backend (str or BackendBase.BackendBase) – The backend to use for the plot.
The default is to use matplotlib.
- 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 ration action.
- yInverted (bool) – Toggle visibility of Y axis direction action.
- 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 silx.gui.plot.PlotTools.PositionInfo.
- roi (bool) – Toggle visibilty of ROI action.
|
-
legendsDockWidget[source]
DockWidget with Legend panel (lazy-loaded).
-
curvesROIDockWidget[source]
DockWidget with curves’ ROI panel (lazy-loaded).
-
roiAction[source]
QAction toggling curve ROI dock widget
-
maskToolsDockWidget[source]
DockWidget with image mask panel (lazy-loaded).
-
maskAction[source]
QAction toggling image mask dock widget
-
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 :attr`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 |
-
consoleDockWidget[source]
DockWidget with IPython console (lazy-loaded).
-
crosshairAction[source]
Action toggling crosshair cursor mode (lazy-loaded).
-
panWithArrowKeysAction[source]
Action toggling pan with arrow keys (lazy-loaded).
-
toolBar(title='Plot', parent=None)[source]
Return a QToolBar from the QAction of the PlotWindow.
Parameters: |
- title (str) – The title of the QMenu
- parent – See QToolBar
|
Return a QMenu from the QAction of the PlotWindow.
Parameters: |
- title (str) – The title of the QMenu
- parent – See QMenu
|
-
class silx.gui.plot.PlotWindow.Plot2D(parent=None)[source]
Bases: silx.gui.plot.PlotWindow.PlotWindow
PlotWindow with a toolbar specific for images.
Parameters: | parent – The parent of this widget |
-
profile = None
“Profile tools attached to this plot.
See silx.gui.plot.PlotTools.ProfileToolBar
-
silx.gui.plot.PlotWindow.plot1D(x_or_y=None, y=None, title='', xlabel='X', ylabel='Y')[source]
Plot curves in a dedicated widget.
Examples:
The following examples must run with a Qt QApplication initialized.
First import plot1D() function:
>>> from silx.gui.plot import plot1D
>>> import numpy
Plot a single curve given some values:
>>> values = numpy.random.random(100)
>>> plot_1curve = plot1D(values, title='Random data')
Plot a single curve given the x and y values:
>>> angles = numpy.linspace(0, numpy.pi, 100)
>>> sin_a = numpy.sin(angles)
>>> plot_sinus = plot1D(angles, sin_a,
... xlabel='angle (radian)', ylabel='sin(a)')
Plot many curves by giving a 2D array:
>>> curves = numpy.random.random(10 * 100).reshape(10, 100)
>>> plot_curves = plot1D(curves)
Plot many curves sharing the same x values:
>>> angles = numpy.linspace(0, numpy.pi, 100)
>>> values = (numpy.sin(angles), numpy.cos(angles))
>>> plot = plot1D(angles, values)
Parameters: |
- x_or_y – x values or y values if y is not provided
- y – y values (x_or_y) must be provided
- title (str) – The title of the Plot widget
- xlabel (str) – The label of the X axis
- ylabel (str) – The label of the Y axis
|
-
silx.gui.plot.PlotWindow.plot2D(data=None, cmap=None, norm='linear', vmin=None, vmax=None, aspect=False, origin=(0.0, 0.0), scale=(1.0, 1.0), title='', xlabel='X', ylabel='Y')[source]
Plot an image in a dedicated widget.
Example to plot an image.
This example must run with a Qt QApplication initialized.
>>> from silx.gui.plot import plot2D
>>> import numpy
>>> data = numpy.random.random(1024 * 1024).reshape(1024, 1024)
>>> plot = plot2D(data, title='Random data')
Parameters: |
- data (numpy.ndarray-like with 2 dimensions) – data to plot as an image
- cmap (str) – The name of the colormap to use for the plot.
- norm (str) – The normalization of the colormap:
‘linear’ (default) or ‘log’
- vmin (float) – The value to use for the min of the colormap
- vmax (float) – The value to use for the max of the colormap
- aspect (bool) – True to keep aspect ratio (Default: False)
- origin (2-tuple of floats) – (ox, oy) The origin of the image in the plot
- scale (2-tuple of floats) – (sx, sy) The scale of the image in the plot
(i.e., the size of the image’s pixel in plot coordinates)
- title (str) – The title of the Plot widget
- xlabel (str) – The label of the X axis
- ylabel (str) – The label of the Y axis
|