Reference — PlotPy 2.7 Manual (original) (raw)
Base classes¶
class plotpy.tools.base.GuiTool(manager: PlotManager, toolbar_id: Any | type[DefaultToolbarID] | None = <class 'plotpy.tools.base.DefaultToolbarID'>)[source]¶
Base class for interactive tool applying on a plot
Parameters:
- manager – plot manager
- toolbar_id – toolbar ID
create_action(manager: PlotManager) → QW.QAction | None[source]¶
Create and return tool’s action
Parameters:
manager – plot manager
Returns:
Tool’s action or None (if tool has no action)
setup_toolbar(toolbar: QToolBar) → None[source]¶
Setup tool’s toolbar
Parameters:
toolbar – toolbar
Create and return menu for the tool’s action
Parameters:
manager – plot manager
set_parent_tool(tool: GuiToolT) → None[source]¶
Used to organize tools automatically in menu items
Parameters:
tool – parent tool
register_plot(baseplot: BasePlot) → None[source]¶
Every BasePlot using this tool should call register_plot to notify the tool about this widget using it
Parameters:
baseplot – base plot
get_active_plot() → BasePlot | None[source]¶
Return the currently active BasePlot or None if no plot is active
update_status(plot: BasePlot) → None[source]¶
Update the status of the tool based on the currently active plot
Can also be called after an action modifying the BasePlot (e.g. in order to update action states when an item is deselected)
Parameters:
plot – base plot
If the tool supports it, this method should install an action in the context menu
Parameters:
- menu – context menu
- plot – base plot
class plotpy.tools.base.GuiToolT¶
alias of TypeVar(‘GuiToolT’, bound=GuiTool)
class plotpy.tools.InteractiveTool(manager: PlotManager, toolbar_id=<class 'plotpy.tools.base.DefaultToolbarID'>, title: str | None = None, icon: str | None = None, tip: str | None = None, switch_to_default_tool: bool | None = None)[source]¶
Interactive tool base class
Parameters:
- manager – plot manager
- toolbar_id – toolbar ID
- title – tool title
- icon – tool icon
- tip – tool tip
- switch_to_default_tool – switch to default tool when finished
SIG_VALIDATE_TOOL(PyQt_PyObject)¶
Signal emitted by InteractiveTool when validating tool action
SIG_TOOL_JOB_FINISHED¶
Signal emitted by InteractiveTool when tool job is finished
create_action(manager: PlotManager) → QW.QAction[source]¶
Create and return tool’s action
Parameters:
manager – plot manager
Returns:
Tool’s action
cursor() → CursorShape[source]¶
Return tool mouse cursor shape
register_plot(baseplot: BasePlot) → None[source]¶
Register plot
Parameters:
baseplot – base plot
interactive_triggered(action: QAction) → None[source]¶
Slot called when the interactive tool action group is triggered. The purpose is to deactivate all other tools in the group.
Note that the tool itself has already been activated because the action triggered the activate method.
Parameters:
action – tool action
Activate tool
Deactivate tool
validate(filter: StatefulEventFilter, event: QEvent) → None[source]¶
Validate tool action
Parameters:
- filter – event filter
- event – event
class plotpy.tools.CommandTool(manager: PlotManager, title: str, icon: str | None = None, tip: str | None = None, toolbar_id: Any | type[DefaultToolbarID] | None = <class 'plotpy.tools.base.DefaultToolbarID'>)[source]¶
Base class for command tools: action, context menu entry
Parameters:
- manager – plot manager
- title – tool title
- icon – tool icon
- tip – tool tip
- toolbar_id – toolbar ID
create_action(manager: PlotManager) → QW.QAction[source]¶
Create and return tool’s action
Parameters:
manager – plot manager
Returns:
Tool’s action
setup_context_menu(menu: QW.QMenu, plot: BasePlot) → None[source]¶
Setup context menu
Parameters:
- menu – context menu
- plot – base plot
activate(checked: bool = True) → None[source]¶
Activate tool
Parameters:
checked – checked
activate_command(plot: BasePlot, checked: bool) → None[source]¶
Activate tool command
Parameters:
- plot – base plot
- checked – checked
set_status_active_item(plot: BasePlot) → None[source]¶
Set status active item
Parameters:
plot – base plot
class plotpy.tools.ActionTool(manager: PlotManager, action: QW.QAction, item_types: Any | None = None, toolbar_id=<class 'plotpy.tools.base.DefaultToolbarID'>)[source]¶
Tool that simply associate an action to a tool
Parameters:
- manager – plot manager
- action – action
- item_types – item types
- toolbar_id – toolbar ID
update_status(plot: BasePlot) → None[source]¶
Update the status of the tool based on the currently active plot
Can also be called after an action modifying the BasePlot (e.g. in order to update action states when an item is deselected)
Parameters:
plot – base plot
create_action(manager: PlotManager) → QW.QAction[source]¶
Create and return tool’s action
Parameters:
manager – plot manager
Returns:
Tool’s action
class plotpy.tools.PanelTool(manager: PlotManager)[source]¶
Panel tool base class
Parameters:
manager – plot manager
activate_command(plot: BasePlot, checked: bool) → None[source]¶
Activate tool command
Parameters:
- plot – base plot
- checked – checked
update_status(plot: BasePlot) → None[source]¶
Update the status of the tool based on the currently active plot
Can also be called after an action modifying the BasePlot (e.g. in order to update action states when an item is deselected)
Parameters:
plot – base plot
Plot tools¶
class plotpy.tools.DoAutoscaleTool(manager, title='AutoScale', icon='autoscale.png', tip=None, toolbar_id=<class 'plotpy.tools.base.DefaultToolbarID'>)[source]¶
A tool to perform autoscale for associated plot.
Set up the context menu for the tool.
Parameters:
- menu – Context menu
- plot – Plot instance
activate_command(plot: BasePlot, checked: bool) → None[source]¶
Activate tool.
Parameters:
- plot – Plot instance
- checked – Whether the tool is checked
class plotpy.tools.DisplayCoordsTool(manager)[source]¶
Tool for displaying coordinates.
Create and return menu for the tool’s action.
Parameters:
manager – Plot manager
Returns:
Menu for the tool’s action
activate_canvas_pointer(enable: bool) → None[source]¶
Activate canvas pointer.
Parameters:
enable – Whether to enable the canvas pointer
activate_curve_pointer(enable: bool) → None[source]¶
Activate curve pointer.
Parameters:
enable – Whether to enable the curve pointer
update_status(plot: BasePlot) → None[source]¶
Update the status of the tool.
Parameters:
plot – Plot instance
class plotpy.tools.RectZoomTool(manager: PlotManager, toolbar_id=<class 'plotpy.tools.base.DefaultToolbarID'>, title: str | None = None, icon: str | None = None, tip: str | None = None, switch_to_default_tool: bool | None = None)[source]¶
setup_filter(baseplot)[source]¶
Parameters:
baseplot
Returns:
Returns:
class plotpy.tools.DummySeparatorTool(manager, toolbar_id=<class 'plotpy.tools.base.DefaultToolbarID'>)[source]¶
setup_toolbar(toolbar)[source]¶
Setup tool’s toolbar
Parameters:
- menu
- plot
class plotpy.tools.RectangularSelectionTool(manager, intersect=True, toolbar_id=<class 'plotpy.tools.base.DefaultToolbarID'>)[source]¶
Item tools¶
class plotpy.tools.SelectTool(manager: PlotManager, toolbar_id=<class 'plotpy.tools.base.DefaultToolbarID'>, title: str | None = None, icon: str | None = None, tip: str | None = None, switch_to_default_tool: bool | None = None)[source]¶
Graphical Object Selection Tool
setup_filter(baseplot: BasePlot) → int[source]¶
Set up the event filter for the tool.
Parameters:
baseplot – Base plot instance
Returns:
Start state of the filter
select_all_items(filter: StatefulEventFilter, event: QEvent) → None[source]¶
Select all items in the plot.
Parameters:
- filter – Event filter
- event – Event that triggered the selection
move_with_arrow(filter: StatefulEventFilter, event: QKeyEvent) → None[source]¶
Move selected items with arrow keys.
Parameters:
- filter – Event filter
- event – Key event
rotate_with_arrow(filter: StatefulEventFilter, event: QKeyEvent) → None[source]¶
Rotate selected items with arrow keys.
Parameters:
- filter – Event filter
- event – Key event
class plotpy.tools.ItemListPanelTool(manager: PlotManager)[source]¶
Tool for managing the item list panel.
class plotpy.tools.SaveItemsTool(manager, toolbar_id: str | type[~plotpy.tools.base.DefaultToolbarID] = <class 'plotpy.tools.base.DefaultToolbarID'>)[source]¶
activate_command(plot: BasePlot, checked: bool) → None[source]¶
Activate tool command.
Parameters:
- plot – Plot instance
- checked – Whether the tool is checked
class plotpy.tools.LoadItemsTool(manager, toolbar_id: str | type[~plotpy.tools.base.DefaultToolbarID] = <class 'plotpy.tools.base.DefaultToolbarID'>)[source]¶
activate_command(plot: BasePlot, checked: bool) → None[source]¶
Activate tool command.
Parameters:
- plot – Plot instance
- checked – Whether the tool is checked
class plotpy.tools.ExportItemDataTool(manager, toolbar_id: str | type[DefaultToolbarID] | None = None)[source]¶
Tool for exporting item data.
class plotpy.tools.EditItemDataTool(manager, toolbar_id: str | type[DefaultToolbarID] | None = None)[source]¶
Tool for editing item data.
class plotpy.tools.ItemCenterTool(manager, toolbar_id: str | type[DefaultToolbarID] | None = None)[source]¶
Tool for centering items.
get_supported_items(plot: BasePlot) → list[source]¶
Get supported items from the plot.
Parameters:
plot – Plot instance
Returns:
List of supported plot items
update_status(plot: BasePlot) → None[source]¶
Update the status of the tool.
Parameters:
plot – Plot instance
activate_command(plot: BasePlot, checked: bool) → None[source]¶
Activate tool command.
Parameters:
- plot – Plot instance
- checked – Whether the tool is checked
class plotpy.tools.DeleteItemTool(manager, toolbar_id: str | type[DefaultToolbarID] | None = None)[source]¶
get_removable_items(plot: BasePlot) → list[source]¶
Get removable items from the plot.
Parameters:
plot – Plot instance
Returns:
List of removable plot items
update_status(plot: BasePlot) → None[source]¶
Update the status of the tool.
Parameters:
plot – Plot instance
activate_command(plot: BasePlot, checked: bool) → None[source]¶
Activate tool command.
Parameters:
- plot – Plot instance
- checked – Whether the tool is checked
Shape tools¶
class plotpy.tools.MultiLineTool(manager, setup_shape_cb: ~typing.Callable | None = None, handle_final_shape_cb: ~typing.Callable | None = None, shape_style: tuple[str, str] | None = None, toolbar_id: str = <class 'plotpy.tools.base.DefaultToolbarID'>, title: str | None = None, icon: str | None = None, tip: str | None = None, switch_to_default_tool: bool | None = None)[source]¶
A tool for drawing multi-line shapes (polylines) on a plot.
This tool allows users to create polyline shapes by clicking on the plot to add points. The shape can be finalized using the Enter or Space key.
Parameters:
- manager – The plot manager.
- handle_final_shape_cb – Callback function to handle the final shape.
- shape_style – Tuple containing the style section and key for the shape.
- toolbar_id – ID of the toolbar to which this tool belongs.
- title – Title of the tool.
- icon – Icon for the tool.
- tip – Tooltip for the tool.
- switch_to_default_tool – Whether to switch to the default tool after use.
set_shape_style(shape: PolygonShape) → None[source]¶
Set shape style
Parameters:
shape – shape
create_shape() → PolygonShape[source]¶
Create shape
setup_shape(shape: PolygonShape) → None[source]¶
Setup shape
get_shape() → PolygonShape[source]¶
Get shape
Returns:
shape
setup_filter(baseplot: BasePlot) → StatefulEventFilter[source]¶
Set up the event filter for the tool.
Parameters:
baseplot – The base plot object.
Returns:
The configured filter.
handle_final_shape(shape) → None[source]¶
Handle the final shape after it’s been created.
Parameters:
shape – The final shape object.
end_polyline(filter: StatefulEventFilter, points: ndarray) → None[source]¶
End the polyline and reset the tool.
Parameters:
- filter – The plot filter.
- points – The points of the polyline.
class plotpy.tools.PolygonTool(manager, setup_shape_cb: ~typing.Callable | None = None, handle_final_shape_cb: ~typing.Callable | None = None, shape_style: tuple[str, str] | None = None, toolbar_id: str = <class 'plotpy.tools.base.DefaultToolbarID'>, title: str | None = None, icon: str | None = None, tip: str | None = None, switch_to_default_tool: bool | None = None)[source]¶
A tool for drawing free-form shapes on a plot.
This tool extends the MultiLineTool to create closed shapes when there are more than 2 points.
class plotpy.tools.LabelTool(manager, handle_label_cb=None, label_style=None, toolbar_id=<class 'plotpy.tools.base.DefaultToolbarID'>, title=None, icon=None, tip=None, switch_to_default_tool=None)[source]¶
set_label_style(label)[source]¶
Parameters:
label
setup_filter(baseplot)[source]¶
Parameters:
baseplot
Returns:
add_label_to_plot(filter, event)[source]¶
Parameters:
- filter
- event
class plotpy.tools.RectangularShapeTool(manager, setup_shape_cb: ~typing.Callable | None = None, handle_final_shape_cb: ~typing.Callable | None = None, shape_style: tuple[str, str] | None = None, toolbar_id: str = <class 'plotpy.tools.base.DefaultToolbarID'>, title: str | None = None, icon: str | None = None, tip: str | None = None, switch_to_default_tool: bool | None = None)[source]¶
Base class for tools that create rectangular shapes.
Parameters:
- manager – The plot manager.
- setup_shape_cb – Callback function to set up the shape.
- handle_final_shape_cb – Callback function to handle the final shape.
- shape_style – Tuple containing the style section and key for the shape.
- toolbar_id – ID of the toolbar to which this tool belongs.
- title – Title of the tool.
- icon – Icon for the tool.
- tip – Tooltip for the tool.
- switch_to_default_tool – Whether to switch to the default tool after use.
add_shape_to_plot(plot, p0: QPointF, p1: QPointF)[source]¶
Add the final shape to the plot.
Parameters:
- plot – The plot object.
- p0 – The first point of the shape.
- p1 – The second point of the shape.
setup_shape(shape) → None[source]¶
Set up the shape properties.
Parameters:
shape – The shape object to set up.
handle_final_shape(shape) → None[source]¶
Handle the final shape after it’s been created.
Parameters:
shape – The final shape object.
class plotpy.tools.RectangleTool(manager, setup_shape_cb: ~typing.Callable | None = None, handle_final_shape_cb: ~typing.Callable | None = None, shape_style: tuple[str, str] | None = None, toolbar_id: str = <class 'plotpy.tools.base.DefaultToolbarID'>, title: str | None = None, icon: str | None = None, tip: str | None = None, switch_to_default_tool: bool | None = None)[source]¶
Tool for creating rectangle shapes.
class plotpy.tools.PointTool(manager, setup_shape_cb: ~typing.Callable | None = None, handle_final_shape_cb: ~typing.Callable | None = None, shape_style: tuple[str, str] | None = None, toolbar_id: str = <class 'plotpy.tools.base.DefaultToolbarID'>, title: str | None = None, icon: str | None = None, tip: str | None = None, switch_to_default_tool: bool | None = None)[source]¶
Tool for creating point shapes.
Create a point shape.
Returns:
A tuple containing the shape object and its handle indices.
get_selection_handler(filter, start_state)[source]¶
Get the selection handler for the point tool.
Parameters:
- filter – The plot filter.
- start_state – The initial state.
Returns:
A PointSelectionHandler object.
class plotpy.tools.SegmentTool(manager, setup_shape_cb: ~typing.Callable | None = None, handle_final_shape_cb: ~typing.Callable | None = None, shape_style: tuple[str, str] | None = None, toolbar_id: str = <class 'plotpy.tools.base.DefaultToolbarID'>, title: str | None = None, icon: str | None = None, tip: str | None = None, switch_to_default_tool: bool | None = None)[source]¶
Tool for creating segment shapes.
Create a segment shape.
Returns:
A tuple containing the shape object and its handle indices.
class plotpy.tools.CircleTool(manager, setup_shape_cb: ~typing.Callable | None = None, handle_final_shape_cb: ~typing.Callable | None = None, shape_style: tuple[str, str] | None = None, toolbar_id: str = <class 'plotpy.tools.base.DefaultToolbarID'>, title: str | None = None, icon: str | None = None, tip: str | None = None, switch_to_default_tool: bool | None = None)[source]¶
Tool for creating circle shapes.
Create a circle shape.
Returns:
A tuple containing the shape object and its handle indices.
class plotpy.tools.EllipseTool(manager, setup_shape_cb: ~typing.Callable | None = None, handle_final_shape_cb: ~typing.Callable | None = None, shape_style: tuple[str, str] | None = None, toolbar_id: str = <class 'plotpy.tools.base.DefaultToolbarID'>, title: str | None = None, icon: str | None = None, tip: str | None = None, switch_to_default_tool: bool | None = None)[source]¶
Tool for creating ellipse shapes.
Create an ellipse shape.
Returns:
A tuple containing the shape object and its handle indices.
handle_final_shape(shape) → None[source]¶
Handle the final ellipse shape after it’s been created.
Parameters:
shape – The final ellipse shape object.
class plotpy.tools.AnnotatedRectangleTool(manager, setup_shape_cb: ~typing.Callable | None = None, handle_final_shape_cb: ~typing.Callable | None = None, shape_style: tuple[str, str] | None = None, toolbar_id: str = <class 'plotpy.tools.base.DefaultToolbarID'>, title: str | None = None, icon: str | None = None, tip: str | None = None, switch_to_default_tool: bool | None = None)[source]¶
Tool for creating annotated rectangle shapes.
This tool extends the RectangleTool to create AnnotatedRectangle objects.
create_shape() → tuple[AnnotatedRectangle, int, int][source]¶
Create an annotated rectangle shape.
Returns:
A tuple containing the AnnotatedRectangle object and its handle indices.
class plotpy.tools.AnnotatedCircleTool(manager, setup_shape_cb: ~typing.Callable | None = None, handle_final_shape_cb: ~typing.Callable | None = None, shape_style: tuple[str, str] | None = None, toolbar_id: str = <class 'plotpy.tools.base.DefaultToolbarID'>, title: str | None = None, icon: str | None = None, tip: str | None = None, switch_to_default_tool: bool | None = None)[source]¶
Tool for creating annotated circle shapes.
This tool extends the CircleTool to create AnnotatedCircle objects.
create_shape() → tuple[AnnotatedCircle, int, int][source]¶
Create an annotated circle shape.
Returns:
A tuple containing the AnnotatedCircle object and its handle indices.
class plotpy.tools.AnnotatedEllipseTool(manager, setup_shape_cb: ~typing.Callable | None = None, handle_final_shape_cb: ~typing.Callable | None = None, shape_style: tuple[str, str] | None = None, toolbar_id: str = <class 'plotpy.tools.base.DefaultToolbarID'>, title: str | None = None, icon: str | None = None, tip: str | None = None, switch_to_default_tool: bool | None = None)[source]¶
Tool for creating annotated ellipse shapes.
This tool extends the EllipseTool to create AnnotatedEllipse objects.
create_shape() → tuple[AnnotatedEllipse, int, int][source]¶
Create an annotated ellipse shape.
Returns:
A tuple containing the AnnotatedEllipse object and its handle indices.
class plotpy.tools.AnnotatedPointTool(manager, setup_shape_cb: ~typing.Callable | None = None, handle_final_shape_cb: ~typing.Callable | None = None, shape_style: tuple[str, str] | None = None, toolbar_id: str = <class 'plotpy.tools.base.DefaultToolbarID'>, title: str | None = None, icon: str | None = None, tip: str | None = None, switch_to_default_tool: bool | None = None)[source]¶
Tool for creating annotated point shapes.
This tool extends the PointTool to create AnnotatedPoint objects.
create_shape() → tuple[AnnotatedPoint, int, int][source]¶
Create an annotated point shape.
Returns:
A tuple containing the AnnotatedPoint object and its handle indices.
class plotpy.tools.AnnotatedSegmentTool(manager, setup_shape_cb: ~typing.Callable | None = None, handle_final_shape_cb: ~typing.Callable | None = None, shape_style: tuple[str, str] | None = None, toolbar_id: str = <class 'plotpy.tools.base.DefaultToolbarID'>, title: str | None = None, icon: str | None = None, tip: str | None = None, switch_to_default_tool: bool | None = None)[source]¶
Tool for creating annotated segment shapes.
This tool extends the SegmentTool to create AnnotatedSegment objects.
create_shape() → tuple[AnnotatedSegment, int, int][source]¶
Create an annotated segment shape.
Returns:
A tuple containing the AnnotatedSegment object and its handle indices.
class plotpy.tools.AnnotatedPolygonTool(manager, setup_shape_cb: ~typing.Callable | None = None, handle_final_shape_cb: ~typing.Callable | None = None, shape_style: tuple[str, str] | None = None, toolbar_id: str = <class 'plotpy.tools.base.DefaultToolbarID'>, title: str | None = None, icon: str | None = None, tip: str | None = None, switch_to_default_tool: bool | None = None)[source]¶
Tool for creating annotated polygon shapes.
This tool extends the PolygonTool to create AnnotatedPolygon objects.
create_shape() → AnnotatedPolygon[source]¶
Create an annotated polygon shape.
Returns:
A tuple containing the AnnotatedPolygon object and its handle indices.
class plotpy.tools.HRangeTool(manager, toolbar_id=<class 'plotpy.tools.base.DefaultToolbarID'>, title=None, icon=None, tip=None, switch_to_default_tool=None)[source]¶
Returns:
Curve tools¶
class plotpy.tools.CurveStatsTool(manager: PlotManager, labelfuncs: tuple[tuple[str, Callable[..., Any]], ...] | None = None, toolbar_id: Any = <class 'plotpy.tools.base.DefaultToolbarID'>, title: str | None = None, icon: str | None = None, tip: str | None = None)[source]¶
Curve statistics tool
Parameters:
- manager – PlotManager Instance
- toolbar_id – Toolbar Id to use. Defaults to DefaultToolbarID.
- title – Tool name. Defaults to None.
- icon – Tool icon path. Defaults to None.
- tip – Available tip. Defaults to None.
- switch_to_default_tool – Wether to use as the default tool or not. Defaults to None.
set_labelfuncs(labelfuncs: tuple[tuple[str, Callable[[...], Any]], ...]) → None[source]¶
Set label functions
Parameters:
labelfuncs – Label functions
Example
labelfuncs = ( ("%g < x < %g", lambda *args: (args[0].min(), args[0].max())), ("%g < y < %g", lambda *args: (args[1].min(), args[1].max())), ("<y>=%g", lambda *args: args[1].mean()), ("σ(y)=%g", lambda *args: args[1].std()), ("∑(y)=%g", lambda *args: spt.trapezoid(args[1])), ("∫ydx=%g", lambda *args: spt.trapezoid(args[1], args[0])), )
get_last_item() → CurveItem | None[source]¶
Get last item on which the tool was used
create_shape() → XRangeSelection[source]¶
Create shape associated with the tool
create_label() → DataInfoLabel[source]¶
Create label associated with the tool
move(filter: StatefulEventFilter, event: QMouseEvent) → None[source]¶
Move tool action
Parameters:
- filter – StatefulEventFilter instance
- event – Qt mouse event
end_move(filter: StatefulEventFilter, event: QMouseEvent) → None[source]¶
End shape move
Parameters:
- filter – StatefulEventFilter instance
- event – Qt mouse event
get_associated_item(plot: BasePlot) → CurveItem | None[source]¶
Get associated item
Parameters:
plot – BasePlot instance
Returns:
curve item or None
update_status(plot: BasePlot) → None[source]¶
Update tool status
Parameters:
plot – BasePlot instance
class plotpy.tools.SelectPointTool(manager: PlotManager, mode: str = 'reuse', on_active_item: bool = False, title: str | None = None, icon: str | None = None, tip: str | None = None, end_callback: Callable[[SelectPointTool], Any] | None = None, toolbar_id=<class 'plotpy.tools.base.DefaultToolbarID'>, marker_style=None, switch_to_default_tool=None)[source]¶
Curve point selection tool
Parameters:
- manager – PlotManager Instance
- mode – Selection mode. Defaults to “reuse”.
- on_active_item – Wether to use the active item or not. Defaults to False.
- title – Tool name. Defaults to None.
- icon – Tool icon path. Defaults to None.
- tip – Available tip. Defaults to None.
- end_callback – Callback function taking a Self instance as argument that will be passed when the user stops dragging the point. Defaults to None.
- toolbar_id – Toolbar Id to use. Defaults to DefaultToolbarID.
- marker_style – Marker style. Defaults to None.
- switch_to_default_tool – Wether to use as the default tool or not. Defaults to None.
set_marker_style(marker: Marker) → None[source]¶
Configure marker style
Parameters:
marker – Marker instance
setup_filter(baseplot: BasePlot) → StatefulEventFilter[source]¶
Setup event filter
Parameters:
baseplot – BasePlot instance
Returns:
StatefulEventFilter instance
start(filter: StatefulEventFilter, event: QMouseEvent) → None[source]¶
Start tool action
Parameters:
- filter – StatefulEventFilter instance
- event – Qt mouse event
stop(filter: StatefulEventFilter, event: QMouseEvent) → None[source]¶
Stop tool action
Parameters:
- filter – StatefulEventFilter instance
- event – Qt mouse event
move(filter: StatefulEventFilter, event: QMouseEvent) → None[source]¶
Move tool action
Parameters:
- filter – StatefulEventFilter instance
- event – Qt mouse event
get_coordinates() → tuple[float, float] | None[source]¶
Get last coordinates
class plotpy.tools.SelectPointsTool(manager, mode='reuse', on_active_item=True, title=None, icon=None, tip=None, end_callback: ~typing.Callable[[~plotpy.tools.curve.SelectPointsTool], ~typing.Any] | None = None, toolbar_id=<class 'plotpy.tools.base.DefaultToolbarID'>, marker_style=None, switch_to_default_tool=None, max_select: int | None = None)[source]¶
Curve points selection tool
Parameters:
- manager – PlotManager Instance
- mode – Selection mode. Defaults to “reuse”.
- on_active_item – Wether to use the active item or not. Defaults to False.
- title – Tool name. Defaults to None.
- icon – Tool icon path. Defaults to None.
- tip – Available tip. Defaults to None.
- end_callback – Callback function taking a Self instance as argument that will
- None. (be passed when the user stops dragging the point. Defaults to)
- toolbar_id – Toolbar Id to use. Defaults to DefaultToolbarID.
- marker_style – Marker style. Defaults to None.
- switch_to_default_tool – Wether to use as the default tool or not. Defaults to None.
- max_select – Maximum number of points to select. Defaults to None.
set_marker_style(marker: Marker) → None[source]¶
Configure marker style
Parameters:
marker – Marker instance
setup_filter(baseplot: BasePlot) → StatefulEventFilter[source]¶
Setup event filter
Parameters:
baseplot – BasePlot instance
Returns:
StatefulEventFilter instance
start_single_selection(filter: StatefulEventFilter, event: QMouseEvent) → None[source]¶
Start single selection
Parameters:
- filter – StatefulEventFilter instance
- event – Qt mouse event
start_multi_selection(filter: StatefulEventFilter, event: QMouseEvent) → None[source]¶
Start multi selection
Parameters:
- filter – StatefulEventFilter instance
- event – Qt mouse event
move(filter: StatefulEventFilter, event: QMouseEvent) → None[source]¶
Move tool action
Parameters:
- filter – StatefulEventFilter instance
- event – Qt mouse event
common_stop(filter: StatefulEventFilter, event: QMouseEvent) → None[source]¶
Common stop action
Parameters:
- filter – StatefulEventFilter instance
- event – Qt mouse event
stop_single_selection(filter: StatefulEventFilter, event: QMouseEvent) → None[source]¶
Stop single selection
Parameters:
- filter – StatefulEventFilter instance
- event – Qt mouse event
stop_multi_selection(filter: StatefulEventFilter, event: QMouseEvent) → None[source]¶
Stop multi selection
Parameters:
- filter – StatefulEventFilter instance
- event – Qt mouse event
toggle_marker(marker: Marker) → bool[source]¶
Toggle marker
Parameters:
marker – Marker instance
Returns:
Wether the marker was added or not
Return type:
clear_markers(exclude_detach: tuple[Marker, ...] | None = None) → None[source]¶
Clear markers
Parameters:
exclude_detach – Markers to exclude from detachment. Defaults to None.
update_labels(filter: StatefulEventFilter) → None[source]¶
Update labels
Parameters:
filter – StatefulEventFilter instance
get_coordinates() → tuple[tuple[float, float], ...][source]¶
Get all selected coordinates
class plotpy.tools.EditPointTool(manager: PlotManager, toolbar_id=<class 'plotpy.tools.base.DefaultToolbarID'>, title: str | None = None, icon: str | None = None, tip: str | None = None, switch_to_default_tool: bool | None = None, end_callback: Callable[[EditPointTool], Any] | None = None)[source]¶
Curve point edition tool
Parameters:
- manager – PlotManager Instance
- toolbar_id – Toolbar Id to use . Defaults to DefaultToolbarID.
- title – Tool name. Defaults to None.
- icon – Tool icon path. Defaults to None.
- tip – Available tip. Defaults to None.
- switch_to_default_tool – Wether to use as the default tool or not. Defaults to None.
- end_callback – Callback function taking a Self instance as argument that will
- None. (be passed when the user stops dragging the point. Defaults to)
set_marker_style(marker: Marker) → None[source]¶
Configure marker style
Parameters:
marker – Marker instance
setup_filter(baseplot: BasePlot) → StatefulEventFilter[source]¶
Setup event filter
Parameters:
baseplot – BasePlot instance
Returns:
StatefulEventFilter instance
undo_curve_modifications(filter: StatefulEventFilter, _event: QEvent | None) → None[source]¶
Undo all curve modifications
Parameters:
- filter – StatefulEventFilter instance
- _event – Event instance
trigger_insert_point_at_selection() → None[source]¶
Trigger insert point at selection
insert_point_at_selection(filter: StatefulEventFilter, _event: QEvent | None = None) → None[source]¶
Insert point at selection
Parameters:
- filter – StatefulEventFilter instance
- _event – Event instance
property downsampled_x_: ndarray_¶
Downsampled x array
property downsampled_y_: ndarray_¶
Downsampled y array
start(filter: StatefulEventFilter, event: QMouseEvent) → None[source]¶
Start tool action
Parameters:
- filter – StatefulEventFilter instance
- event – Qt mouse event
move_point(filter: StatefulEventFilter, event: QMouseEvent) → None[source]¶
Move point
Parameters:
- filter – StatefulEventFilter instance
- event – Qt mouse event
stop(filter: StatefulEventFilter, event: QMouseEvent) → None[source]¶
Stop tool action and save new x and y coordinates.
Parameters:
- filter – StatefulEventFilter instance
- event – Qt mouse event
get_changes() → dict[CurveItem, dict[int, tuple[float, float]]][source]¶
Get changes
get_arrays() → tuple[ndarray | None, ndarray | None][source]¶
Get arrays
get_initial_arrays() → tuple[ndarray | None, ndarray | None][source]¶
Get initial arrays
reset_arrays() → None[source]¶
Reset tool arrays to initial values and reset curve item data
Image tools¶
class plotpy.tools.ImageStatsTool(manager, setup_shape_cb: Callable[[AbstractShape], None] | None = None, handle_final_shape_cb: Callable[[AbstractShape], None] | None = None, shape_style: tuple[str, str] | None = None, toolbar_id: Any | type[DefaultToolbarID] = <class 'plotpy.tools.base.DefaultToolbarID'>, title: str | None = None, icon: str | None = None, tip: str | None = None, stats_func: Callable[[BaseImageItem, float, float, float, float]] | None = None, replace: bool = False)[source]¶
Tool to display image statistics in a rectangle
Parameters:
- manager – PlotManager instance
- setup_shape_cb – Callback called after shape setup. Defaults to None.
- handle_final_shape_cb – Callback called when handling final shape.
- None. (Defaults to)
- shape_style – tuple of string to set the shape style. Defaults to None.
- toolbar_id – toolbar id to use. Defaults to DefaultToolbarID. Defaults to
- DefaultToolbarID.
- title – tool title. Defaults to None.
- icon – tool icon filename. Defaults to None.
- tip – user tip to be displayed. Defaults to None.
- stats_func – function to get statistics. Defaults to None. (see
get_stats()
for signature and default implementation) - replace – True to replace stats (statistics are not added to the base infos but replace them). Defaults to False.
Note
The stats_func function should return a formatted string with statistics on the image rectangular area. The function signature should be:
def stats_func(item, x0, y0, x1, y1): return formatted_string
where item is the image item, x0, y0, x1, y1 are the rectangle coordinates and formatted_string is the formatted string with statistics on the image rectangular area.
Default implementation is the following:
def get_stats( item: BaseImageItem, x0: float, y0: float, x1: float, y1: float, ) -> str: """Return formatted string with stats on image rectangular area (output should be compatible with AnnotatedShape.get_infos)
Args:
item: image item
x0: X0
y0: Y0
x1: X1
y1: Y1
"""
ix0, iy0, ix1, iy1 = item.get_closest_index_rect(x0, y0, x1, y1)
data = item.data[iy0:iy1, ix0:ix1]
p: BaseImageParam = item.param
return "<br>".join(
[
"%sx%s %s" % (item.data.shape[1], item.data.shape[0], str(item.data.dtype)),
"",
"%s ≤ x ≤ %s" % (p.xformat % x0, p.xformat % x1),
"%s ≤ y ≤ %s" % (p.yformat % y0, p.yformat % y1),
"%s ≤ z ≤ %s" % (p.zformat % data.min(), p.zformat % data.max()),
"‹z› = " + p.zformat % data.mean(),
"σ(z) = " + p.zformat % data.std(),
]
)
set_stats_func(stats_func: Callable[[BaseImageItem, float, float, float, float]], replace: bool = False) → None[source]¶
Set the function to get statistics
Parameters:
- stats_func – function to get statistics (see
get_stats()
for signature and default implementation) - replace – True to replace stats (statistics are not added to the base infos but replace them). Defaults to False.
get_last_item() → BaseImageItem | None[source]¶
Last image item getter
Returns:
Returns last image item or None
create_shape() → tuple[ImageStatsRectangle, Literal[0], Literal[2]][source]¶
Returns a new ImageStatsRectangle instance and the index of handles to display.
Returns:
New ImageStatsRectangle instance
setup_shape(shape: ImageStatsRectangle) → None[source]¶
Setup and registers given shape.
Parameters:
shape – Shape to setup
register_shape(shape: ImageStatsRectangle, final=False) → None[source]¶
Register given shape
Parameters:
- shape – Shape to register
- final – unused argument. Defaults to False.
handle_final_shape(shape: ImageStatsRectangle) → None[source]¶
Handle final shape
Parameters:
shape – Shape to handled and register
get_associated_item(plot: BasePlot) → BaseImageItem | None[source]¶
Return a reference to the last image item associated with the tool
Parameters:
plot – Plot instance
Returns:
Reference to the last image item associated with the tool
update_status(plot: BasePlot) → None[source]¶
Update tool status if the plot type is not PlotType.CURVE.
Parameters:
plot – Plot instance
class plotpy.tools.RotationCenterTool(manager: BasePlot, toolbar_id: Any | type[DefaultToolbarID] = <class 'plotpy.tools.base.DefaultToolbarID'>, title: str | None = None, icon: str | None = None, tip: str | None = None, switch_to_default_tool=True, rotation_point_move_with_shape=True, rotation_center=True, on_all_items=True)[source]¶
Tool to set the rotation center of an image
Parameters:
- manager – PlotManager instance
- toolbar_id – toolbar id to use. Defaults to DefaultToolbarID.. Defaults to DefaultToolbarID.
- title – tool title. Defaults to None.
- icon – tool icon filename. Defaults to None.
- tip – user tip to be displayed. Defaults to None.
- switch_to_default_tool – Flag to switch to default tool. Defaults to True.
- rotation_point_move_with_shape – Flag to move rotation point with shape when it is moved. Defaults to True.
- rotation_center – True if image already has a rotation center, False otherwise.
- on_all_items – True if rotation center should be set on all items or False if only on selected ones. Defaults to True.
setup_filter(baseplot: BasePlot) → int[source]¶
Setup event filter and connect signals.
Parameters:
baseplot – Plot instance
Returns:
plot’s filter new start state
update_status(plot: BasePlot) → None[source]¶
Updates the tool status depending on the selected items in the given plot.
Parameters:
plot – Plot instance
action_triggered(checked: bool) → None[source]¶
Action triggered slot
Parameters:
checked – unused argument
mouse_press(filter: StatefulEventFilter, event: QEvent) → None[source]¶
We create a new shape if it’s the first point otherwise we add a new point.
Parameters:
- filter – StatefulEventFilter instance
- event – QEvent instance
class plotpy.tools.ReverseYAxisTool(manager: PlotManager)[source]¶
Togglable tool to reverse Y axis
Parameters:
manager – PlotManager Instance
class plotpy.tools.ZAxisLogTool(manager: PlotManager)[source]¶
Patched tools.ToggleTool
activate_command(plot: BasePlot, checked: bool) → None[source]¶
Reimplement tools.ToggleTool method
get_supported_items(plot: BasePlot) → list[BaseImageItem][source]¶
Reimplement tools.ToggleTool method
update_status(plot: BasePlot) → None[source]¶
Reimplement tools.ToggleTool method
class plotpy.tools.AspectRatioTool(manager: PlotManager)[source]¶
Tool to manage the aspect ratio of a plot
Parameters:
manager – PlotManager instance
Create and return menu for the tool’s action
set_aspect_ratio_1_1() → None[source]¶
Reset current aspect ratio to 1:1
activate_command(plot: BasePlot, checked: bool) → None[source]¶
Triggers tool action.
Parameters:
- plot – Plot instance
- checked – True if tool is checked, False otherwise
lock_aspect_ratio(checked: bool) → None[source]¶
Lock aspect ratio depending on given checked state.
Parameters:
checked – True if aspect ratio should be locked, False otherwise
edit_aspect_ratio() → None[source]¶
Edit the aspect ratio with a dataset dialog
update_status(plot: BasePlot) → None[source]¶
Update tool status if the plot type is not PlotType.CURVE.
Parameters:
plot – Plot instance
class plotpy.tools.ContrastPanelTool(manager: PlotManager)[source]¶
Tools to adjust contrast using a dataset dialog
update_status(plot: BasePlot) → None[source]¶
Update tool status.
Parameters:
plot – Plot Instance
class plotpy.tools.ColormapTool(manager: PlotManager, toolbar_id=<class 'plotpy.tools.base.DefaultToolbarID'>)[source]¶
Tool used to select and manage colormaps (inculding visualization, edition and saving).
Parameters:
- manager – PlotManager Instance
- toolbar_id – Toolbar Id to use. Defaults to DefaultToolbarID.
activate_command(plot: BasePlot, checked: bool) → None[source]¶
Triggers tool action.
Parameters:
- plot – Plot instance
- checked – True if tool is checked, False otherwise
activate_cmap(cmap: str | EditableColormap) → None[source]¶
Activate the given colormap. Supports mutliple input types.
Parameters:
cmap – Cmap to apply for currently selected images.
update_plot(cmap_name: str) → None[source]¶
Update the plot with the given colormap.
Parameters:
cmap_name – Colormap name
update_status(plot: BasePlot) → None[source]¶
Update tool status if the plot type is not PlotType.CURVE.
Parameters:
plot – Plot Instance
class plotpy.tools.ReverseColormapTool(manager: PlotManager)[source]¶
Togglable tool to reverse colormap
Parameters:
manager – PlotManager Instance
activate_command(plot: BasePlot, checked: bool) → None[source]¶
Triggers tool action.
Parameters:
- plot – Plot instance
- checked – True if tool is checked, False otherwise
update_status(plot: BasePlot) → None[source]¶
Update tool status if the plot type is not PlotType.CURVE.
Parameters:
plot – Plot instance
class plotpy.tools.LockLUTRangeTool(manager: PlotManager)[source]¶
Togglable tool to keep LUT range when updating image data
Parameters:
manager – PlotManager Instance
activate_command(plot: BasePlot, checked: bool) → None[source]¶
Triggers tool action.
Parameters:
- plot – Plot instance
- checked – True if tool is checked, False otherwise
update_status(plot: BasePlot) → None[source]¶
Update tool status if the plot type is not PlotType.CURVE.
Parameters:
plot – Plot instance
class plotpy.tools.XCSPanelTool(manager: PlotManager)[source]¶
class plotpy.tools.YCSPanelTool(manager: PlotManager)[source]¶
class plotpy.tools.CrossSectionTool(manager, setup_shape_cb: ~typing.Callable | None = None, handle_final_shape_cb: ~typing.Callable | None = None, shape_style: tuple[str, str] | None = None, toolbar_id: str = <class 'plotpy.tools.base.DefaultToolbarID'>, title: str | None = None, icon: str | None = None, tip: str | None = None, switch_to_default_tool: bool | None = None)[source]¶
update_status(plot: BasePlot) → None[source]¶
Update status of the tool
create_shape() → AnnotatedPoint[source]¶
Create shape for the tool
setup_shape(shape: AnnotatedPoint) → None[source]¶
Set up shape for the tool
setup_shape_appearance(shape: AnnotatedPoint) → None[source]¶
Set up shape appearance
register_shape(shape: AnnotatedPoint) → None[source]¶
Register shape
Activate tool
handle_final_shape(shape: AnnotatedPoint) → None[source]¶
Handle final shape
class plotpy.tools.AverageCrossSectionTool(manager, setup_shape_cb: ~typing.Callable | None = None, handle_final_shape_cb: ~typing.Callable | None = None, shape_style: tuple[str, str] | None = None, toolbar_id: str = <class 'plotpy.tools.base.DefaultToolbarID'>, title: str | None = None, icon: str | None = None, tip: str | None = None, switch_to_default_tool: bool | None = None)[source]¶
create_shape() → AnnotatedRectangle[source]¶
Create shape for the tool
class plotpy.tools.LineCrossSectionTool(manager, setup_shape_cb: ~typing.Callable | None = None, handle_final_shape_cb: ~typing.Callable | None = None, shape_style: tuple[str, str] | None = None, toolbar_id: str = <class 'plotpy.tools.base.DefaultToolbarID'>, title: str | None = None, icon: str | None = None, tip: str | None = None, switch_to_default_tool: bool | None = None)[source]¶
create_shape() → AnnotatedSegment[source]¶
Create shape for the tool
class plotpy.tools.ImageMaskTool(manager: PlotManager, toolbar_id=<class 'plotpy.tools.base.DefaultToolbarID'>)[source]¶
Tool to manage image masking
Parameters:
- manager – Plot manager instance
- toolbar_id – Toolbar id value
SIG_APPLIED_MASK_TOOL¶
Signal emitted by ImageMaskTool when mask was applied
Create and return the tool’s action menu for a given manager.
Parameters:
manager – PlotManager instance
update_status(plot: BasePlot) → None[source]¶
Enables tool if masked_image is set.
Parameters:
plot – Plot instance
register_plot(baseplot: BasePlot) → None[source]¶
Register plot in the tool instance and connect signals.
Parameters:
baseplot – Plot instance
show_mask(state: bool)[source]¶
Shows the image mask depending on given state and if masked_image is set
Parameters:
state – True to show mask, False otherwise
Applies the mask to the image
remove_all_shapes() → None[source]¶
Prompts the user to removes all shapes from the plot
remove_shapes() → None[source]¶
Removes all shapes from the plot
show_shapes(state: bool) → None[source]¶
Shows the masking shapes depending on given state
Parameters:
state – True to show shapes, False otherwise
handle_shape(shape: AbstractShape, inside: bool) → None[source]¶
Handles given shape and adds it to the plot and sets it to be the current item
find_masked_image(plot: BasePlot) → MaskedImageItem | MaskedXYImageItem | None[source]¶
Finds the masked image item in the given plot
Parameters:
plot – Plot instance
Returns:
MaskedImageItem or MaskedXYImageItem instance if found, None otherwise
create_shapes_from_masked_areas() → None[source]¶
Creates shapes from the masked areas of the masked image (rectangular or ellipse).
set_masked_image(plot: BasePlot) → None[source]¶
Sets the masked image item from the masked image found in the given plot.
Parameters:
plot – Plot instance
items_changed(plot: BasePlot) → None[source]¶
Updates the masked image and the tool status for a given plot.
Parameters:
plot – Plot instance
item_selection_changed(plot: BasePlot) → None[source]¶
Updates the masked image and the tool status for a given plot. :param plot: Plot instance
Prompts the user to clear the image mask (removes all masks)
activate_command(plot: BasePlot, checked=True)[source]¶
Triggers tool action.
Parameters:
- plot – Plot instance
- checked – True if tool is checked, False otherwise
Curve tools¶
class plotpy.tools.AntiAliasingTool(manager: PlotManager)[source]¶
Anti-aliasing tool
Parameters:
manager – PlotManager Instance
activate_command(plot: BasePlot, checked: bool) → None[source]¶
Activate tool
update_status(plot: BasePlot) → None[source]¶
Update tool status
Parameters:
plot – BasePlot instance
class plotpy.tools.DownSamplingTool(manager: PlotManager)[source]¶
Downsample curve tool
Parameters:
- manager – PlotManager Instance
- toolbar_id – Toolbar Id to use . Defaults to DefaultToolbarID.
activate_command(plot: BasePlot, checked: bool) → None[source]¶
Activate tool
Parameters:
- plot – BasePlot instance
- checked – Wether the tool is checked or not
update_status(plot: BasePlot) → None[source]¶
Update tool status
Parameters:
plot – BasePlot instance
Axes tools¶
class plotpy.tools.AxisScaleTool(manager)[source]¶
A tool for changing the scale of plot axes.
This tool provides options to switch between linear and logarithmic scales for both x and y axes.
Create and return menu for the tool’s action.
Parameters:
manager – The plot manager.
Returns:
A QMenu object containing scale options.
update_status(plot) → None[source]¶
Update the status of scale actions based on the current plot scales.
Parameters:
plot – The current plot object.
set_scale(checked: bool, xscale: str, yscale: str) → None[source]¶
Set the scale of the active plot.
Parameters:
- checked – Whether the action is checked.
- xscale – The scale for the x-axis (‘lin’ or ‘log’).
- yscale – The scale for the y-axis (‘lin’ or ‘log’).
class plotpy.tools.PlaceAxesTool(manager, setup_shape_cb: ~typing.Callable | None = None, handle_final_shape_cb: ~typing.Callable | None = None, shape_style: tuple[str, str] | None = None, toolbar_id: str = <class 'plotpy.tools.base.DefaultToolbarID'>, title: str | None = None, icon: str | None = None, tip: str | None = None, switch_to_default_tool: bool | None = None)[source]¶
A tool for placing axes on the plot.
This tool allows users to draw a rectangular shape to define the position and size of the axes on the plot.
create_shape() → tuple[Axes, int, int][source]¶
Create an Axes shape.
Returns:
A tuple containing the Axes object and its handle indices.
Miscellaneous tools¶
class plotpy.tools.SaveAsTool(manager, toolbar_id=<class 'plotpy.tools.base.DefaultToolbarID'>)[source]¶
activate_command(plot, checked)[source]¶
Activate tool
class plotpy.tools.CopyToClipboardTool(manager, toolbar_id=<class 'plotpy.tools.base.DefaultToolbarID'>)[source]¶
activate_command(plot, checked)[source]¶
Activate tool
class plotpy.tools.OpenFileTool(manager, title='Open...', formats='*.*', toolbar_id=<class 'plotpy.tools.base.DefaultToolbarID'>)[source]¶
SIG_OPEN_FILE(QString)¶
Signal emitted by OpenFileTool when a file was opened
Parameters:
filename (str) – The name of the file that was opened
Parameters:
plot
Returns:
activate_command(plot, checked)[source]¶
Activate tool
class plotpy.tools.OpenImageTool(manager: PlotManager, toolbar_id=<class 'plotpy.tools.base.DefaultToolbarID'>)[source]¶
Tool to open an image file
Parameters:
- manager – PlotManager instance
- toolbar_id – Toolbar id value. Defaults to DefaultToolbarID.
class plotpy.tools.SnapshotTool(manager, toolbar_id=<class 'plotpy.tools.base.DefaultToolbarID'>)[source]¶
class plotpy.tools.PrintTool(manager, toolbar_id=<class 'plotpy.tools.base.DefaultToolbarID'>)[source]¶
activate_command(plot, checked)[source]¶
Activate tool
class plotpy.tools.HelpTool(manager, toolbar_id=<class 'plotpy.tools.base.DefaultToolbarID'>)[source]¶
activate_command(plot, checked)[source]¶
Activate tool