PlotTools
: Tool widgets for PlotWidget¶
Set of widgets to associate with a :class:’PlotWidget’.
PositionInfo
class¶
-
class
PositionInfo
(parent=None, plot=None, converters=None)[source]¶ Bases:
PySide2.QtWidgets.QWidget
QWidget displaying coords converted from data coords of the mouse.
Provide this widget with a list of couple:
- A name to display before the data
- A function that takes (x, y) as arguments and returns something that gets converted to a string. If the result is a float it is converted with ‘%.7g’ format.
To run the following sample code, a QApplication must be initialized. First, create a PlotWindow and add a QToolBar where to place the PositionInfo widget.
>>> from silx.gui.plot import PlotWindow >>> from silx.gui import qt
>>> plot = PlotWindow() # Create a PlotWindow to add the widget to >>> toolBar = qt.QToolBar() # Create a toolbar to place the widget in >>> plot.addToolBar(qt.Qt.BottomToolBarArea, toolBar) # Add it to plot
Then, create the PositionInfo widget and add it to the toolbar. The PositionInfo widget is created with a list of converters, here to display polar coordinates of the mouse position.
>>> import numpy >>> from silx.gui.plot.tools import PositionInfo
>>> position = PositionInfo(plot=plot, converters=[ ... ('Radius', lambda x, y: numpy.sqrt(x*x + y*y)), ... ('Angle', lambda x, y: numpy.degrees(numpy.arctan2(y, x)))]) >>> toolBar.addWidget(position) # Add the widget to the toolbar <...> >>> plot.show() # To display the PlotWindow with the position widget
Parameters: - plot – The PlotWidget this widget is displaying data coords from.
- converters – List of 2-tuple: name to display and conversion function from (x, y) in data coords to displayed value. If None, the default, it displays X and Y.
- parent – Parent widget
-
getPlotWidget
()[source]¶ Returns the PlotWidget this widget is attached to or None.
Return type: Union[PlotWidget,None]
-
SNAPPING_DISABLED
= 0¶ No snapping occurs
-
SNAPPING_CROSSHAIR
= 1¶ Snapping only enabled when crosshair cursor is enabled
-
SNAPPING_ACTIVE_ONLY
= 2¶ Snapping only enabled for active item
-
SNAPPING_SYMBOLS_ONLY
= 4¶ Snapping only when symbols are visible
-
SNAPPING_CURVE
= 8¶ Snapping on curves
-
SNAPPING_SCATTER
= 16¶ Snapping on scatter
LimitsToolBar
class¶
-
class
LimitsToolBar
(parent=None, plot=None, title='Limits')[source]¶ Bases:
PySide2.QtWidgets.QToolBar
QToolBar displaying and controlling the limits of a
PlotWidget
.To run the following sample code, a QApplication must be initialized. First, create a PlotWindow:
>>> from silx.gui.plot import PlotWindow >>> plot = PlotWindow() # Create a PlotWindow to add the toolbar to
Then, create the LimitsToolBar and add it to the PlotWindow.
>>> from silx.gui import qt >>> from silx.gui.plot.tools import LimitsToolBar
>>> toolbar = LimitsToolBar(plot=plot) # Create the toolbar >>> plot.addToolBar(qt.Qt.BottomToolBarArea, toolbar) # Add it to the plot >>> plot.show() # To display the PlotWindow with the limits toolbar
Parameters: - parent – See
QToolBar
. - plot –
PlotWidget
instance on which to operate. - title (str) – See
QToolBar
.
-
plot
¶ The
PlotWidget
the toolbar is attached to.
- parent – See
ColorBar
: ColorBar Widget¶
Module containing several widgets associated to a colormap.
ColorBarWidget
class¶
-
class
ColorBarWidget
(parent=None, plot=None, legend=None)[source]¶ Colorbar widget displaying a colormap
It uses a description of colormap as dict compatible with
Plot
.To run the following sample code, a QApplication must be initialized.
>>> from silx.gui.plot import Plot2D >>> from silx.gui.plot.ColorBar import ColorBarWidget
>>> plot = Plot2D() # Create a plot widget >>> plot.show()
>>> colorbar = ColorBarWidget(plot=plot, legend='Colormap') # Associate the colorbar with it >>> colorbar.show()
Initializer parameters:
Parameters: - parent – See
QWidget
- plot – PlotWidget the colorbar is attached to (optional)
- legend (str) – the label to set to the colorbar
-
sigVisibleChanged
= <PySide2.QtCore.Signal object>¶ Emitted when the property visible have changed.
-
setPlot
(plot)[source]¶ Associate a plot to the ColorBar
Parameters: plot – the plot to associate with the colorbar. If None will remove any connection with a previous plot.
-
setColormap
(colormap, data=None)[source]¶ Set the colormap to be displayed.
Parameters: - colormap (Colormap) – The colormap to apply on the ColorBarWidget
- data (numpy.ndarray) – the data to display, needed if the colormap require an autoscale
-
setLegend
(legend)[source]¶ Set the legend displayed along the colorbar
Parameters: legend (str) – The label
- parent – See