10.9. plotItem#
- class itom.plotItem(figure, subplotIdx=0)#
- class itom.plotItem(uiItem) plotItem
- class itom.plotItem(figure, objectID=0) plotItem
Bases:
uiItemThe plotItem is a special
uiItemand represents itom plot designer widgets.This constructor can be used to get a reference of a plot in a
figure. The plot can also be in a subplot area of a figure. There are two main uses cases for the direct usage of this constructor:If a reference to a general
uiItemis available, but the referenced widget / item is a plot, theuiItemcan be cast toplotItemsuch that additional methods likepickPoints()ordrawAndPickElements()become available.If a reference to a
figureis available, that contains one or more plots, the reference to one of these plots can be obtained. ThesubplotIdxindicates the specific plot, that should be referenced. The default is0. If the figure consists of more than one subplot, the index counts the subplots row-by-row.
The 3rd variant of this constructor, using the keyword-based argument
objectIDis only internally used and has no further meaning for a high-level usage. However, if it is used,objectIDmust be used as keyword argument, elsesubplotIdxis assumed to be initialized.- Parameters:
- figure
figure The
figurewindow, that contains an itom plot.- subplotIdx
int,optional The area index of the (sub)plot, that should be referenced. This index is considered to be row-wise, such that the center plot in the 2nd row with three plots in each row has the index
4. The first, left, plot in the first row has the index0, which is the default.- objectID
int,optional If the internal
objectIDof auiItemis available, it can be tried to be casted toplotItem.- uiItem
uiItem Try to cast this
uiItemto its inherited classplotItem. ARuntimeErroris raised if this cast is not possible.
- figure
- Returns:
- drawAndPickElements(elementType, maxNrElements=1) Tuple[shape]#
This method forces the user to draw specific shapes on the canvas of the plot.
If this method is called, the script execution in paused until the requested
maxNrElementsof shapes of the given typeelementTypeare drawn by the user on the canvas of the plot. The coordinates of the shapes is then returned by this method. If the script execution is aborted during the interactive operation or if the user presses theEsckey in the plot, this operation is stopped by aRuntimeError.- Parameters:
- elementType
int The element type that the user should interactively draw on the canvas of the plot. Allowed types are:
plotItem.PrimitivePointplotItem.PrimitiveLineplotItem.PrimitiveRectangleplotItem.PrimitiveSquareplotItem.PrimitiveEllipseplotItem.PrimitiveCircleplotItem.PrimitivePolygon
- maxNrElements
int,optional Number of elements of the given type, the user has to draw. The operation can be aborted by clicking the
Esckey. If this is the case, aRuntimeErroris raised.
- elementType
- Returns:
- Raises:
RuntimeErrorif the user interrupts the selection (by pressing the Esc key).
- pickPoints(points, maxNrPoints=-1)#
-> method to let the user pick points on a plot (only if plot supports this)
This method lets the user select one or multiple points (up to
maxNrPoints) in the canvas of the current plot (if the plot supports this). The operation can be aborted by pressing theEsckey. Then aRuntimeError` is raised. It can also be quit earlier by pressing the ``Spacekey. This is also required if an unlimited number of points can be selected (maxNrPoints = -1).A pick-points operation is not supported by all plot classes. It is for instance available for the classes
itom1dqwtplot(see section line plots (1D)) oritom2dqwtplot(see section image plots (2D)).- Parameters:
- points
dataObject This object will be a
2 x nrOfSelectedPointsdataObjectof dtypefloat64after the successful call of this method. The first row contains thexcoordinates of the selected points, the 2nd row theycoordinates.- maxNrPoints
int,optional Let the user select up to this number of points. The selection can be stopped by pressing Space or Esc.
maxNrPointsmust be -1 for an unlimited number of picked points (default) or a number >= 1.
- points
- Raises:
RuntimeErrorif the specific plot class does not provide the necessary methods to support this operation.
RuntimeErrorif the operation has been interrupted by the user.
pointsis an emptydataObjectthen. An interruption can occur if the plot is closed or if the user pressed the escape key during the operation.
- PrimitiveCircle = 64#
- PrimitiveEllipse = 32#
- PrimitiveLine = 4#
- PrimitiveMultiPointPick = 1#
- PrimitivePoint = 2#
- PrimitivePolygon = 128#
- PrimitiveRectangle = 8#
- PrimitiveSquare = 16#