PlotTools: Tool widgets for PlotWidget

Set of widgets to associate with a :class:’PlotWidget’.

PositionInfo class

class silx.gui.plot.PlotTools.PositionInfo(parent=None, plot=None, converters=None)[source]

Bases: PyQt4.QtGui.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.PlotTools 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 (Iterable of 2-tuple (str, function)) – List of 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
autoSnapToActiveCurve = None

Toggle snapping use position to active curve.

  • True to snap used coordinates to the active curve if the active curve is displayed with symbols and mouse is close enough. If the mouse is not close to a point of the curve, values are displayed in red.
  • False (the default) to always use mouse coordinates.
plot[source]

The PlotWindow this widget is attached to.

getConverters()[source]

Return the list of converters as 2-tuple (name, function).

LimitsToolBar class

class silx.gui.plot.PlotTools.LimitsToolBar(parent=None, plot=None, title='Limits')[source]

Bases: PyQt4.QtGui.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.PlotTools 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.
  • plotPlotWidget instance on which to operate.
  • title (str) – See QToolBar.
plot[source]

The PlotWidget the toolbar is attached to.

Table Of Contents

Previous topic

PlotActions: Actions for PlotWidget

Next topic

Profile: Toolbars with profile tools

This Page