Reference¶
High-level features¶
- class plotpy.plot.manager.PlotManager(main: QWidget)[source]¶
Construct a PlotManager object, a ‘controller’ that organizes relations between plots (
BasePlot
), panels, tools and toolbars- Parameters:
main (QWidget) – The main parent widget
- add_plot(plot: ~plotpy.plot.base.BasePlot, plot_id: ~typing.Any = <class 'plotpy.plot.manager.DefaultPlotID'>) None [source]¶
- Register a plot to the plot manager:
plot:
BasePlot
plot_id (default id is the plot object’s id:
id(plot)
): unique ID identifying the plot (any Python object), this ID will be asked by the manager to access this plot later.
- Plot manager’s registration sequence is the following:
add plots
add panels
add tools
- set_default_plot(plot: BasePlot) None [source]¶
Set default plot
The default plot is the plot on which tools and panels will act.
- get_default_plot() BasePlot [source]¶
Return default plot
The default plot is the plot on which tools and panels will act.
- add_panel(panel: PanelWidget) None [source]¶
Register a panel to the plot manager
- Plot manager’s registration sequence is the following:
add plots
add panels
add tools
- configure_panels() None [source]¶
Call all the registred panels ‘configure_panel’ methods to finalize the object construction (this allows to use tools registered to the same plot manager as the panel itself with breaking the registration sequence: “add plots, then panels, then tools”)
- add_toolbar(toolbar: QToolBar, toolbar_id: str = 'default') None [source]¶
- Add toolbar to the plot manager
toolbar: a QToolBar object toolbar_id: toolbar’s id (default id is string “default”)
- add_tool(ToolKlass: type[GuiToolT], *args, **kwargs) GuiToolT [source]¶
- Register a tool to the manager
ToolKlass: tool’s class (see Plot tools)
args: arguments sent to the tool’s class
kwargs: keyword arguments sent to the tool’s class
- Plot manager’s registration sequence is the following:
add plots
add panels
add tools
- get_tool(ToolKlass: type[GuiToolT]) GuiToolT | None [source]¶
Return tool instance from its class
- Parameters:
ToolKlass – tool’s class (see Plot tools)
- Returns:
tool instance
- Return type:
- add_separator_tool(toolbar_id: str | None = None) None [source]¶
Register a separator tool to the plot manager: the separator tool is just a tool which insert a separator in the plot context menu
- Parameters:
toolbar_id – toolbar’s id (default to None)
- set_active_tool(tool: GuiTool | None = None) None [source]¶
Set active tool (if tool argument is None, the active tool will be the default tool)
- Parameters:
tool – tool instance or None
- get_plot(plot_id: ~typing.Any = <class 'plotpy.plot.manager.DefaultPlotID'>) BasePlot [source]¶
Return plot associated to plot_id (if method is called without specifying the plot_id parameter, return the default plot)
- Parameters:
plot_id – plot’s id (optional, default to DefaultPlotID)
- get_active_plot() BasePlot [source]¶
Return the active plot
The active plot is the plot whose canvas has the focus otherwise it’s the “default” plot
- Returns:
plot instance
- Return type:
- get_tool_group(groupname: str) QActionGroup [source]¶
Return the QActionGroup associated to groupname
- Parameters:
groupname – group’s name
- Returns:
action group
- Return type:
- get_main() QWidget [source]¶
Return the main (parent) widget
Note that for py:class:.plot.PlotWidget objects, this method will return the widget itself because the plot manager is integrated to it.
- Returns:
main widget
- Return type:
- get_panel(panel_id: str) PanelWidget [source]¶
Return panel from its ID Panel IDs are listed in module plotpy.panels
- Parameters:
panel_id – panel’s id
- Returns:
panel widget
- Return type:
- get_itemlist_panel() PlotItemList [source]¶
Convenience function to get the item list panel
Return None if the item list panel has not been added to this manager
- Returns:
item list panel
- Return type:
- get_contrast_panel() ContrastAdjustment [source]¶
Convenience function to get the contrast adjustment panel
Return None if the contrast adjustment panel has not been added to this manager
- set_contrast_range(zmin: float, zmax: float) None [source]¶
Convenience function to set the contrast adjustment panel range
This is strictly equivalent to the following:
# Here, *widget* is for example a PlotWidget instance # (the same apply for PlotWidget or any # class deriving from PlotManager) widget.get_contrast_panel().set_range(zmin, zmax)
- Parameters:
zmin – minimum value
zmax – maximum value
- get_xcs_panel() XCrossSection [source]¶
Convenience function to get the X-axis cross section panel
Return None if the X-axis cross section panel has not been added to this manager
- Returns:
X-axis cross section panel
- Return type:
- get_ycs_panel() YCrossSection [source]¶
Convenience function to get the Y-axis cross section panel
Return None if the Y-axis cross section panel has not been added to this manager
- Returns:
Y-axis cross section panel
- Return type:
- update_cross_sections() None [source]¶
Convenience function to update the cross section panels at once
This is strictly equivalent to the following:
# Here, *widget* is for example a PlotWidget instance # (the same apply for any other class deriving from PlotManager) widget.get_xcs_panel().update_plot() widget.get_ycs_panel().update_plot()
- get_toolbar(toolbar_id: str = 'default') QToolBar [source]¶
Return toolbar from its ID
- Parameters:
toolbar_id – toolbar’s id (default id is string “default”)
- Returns:
toolbar
- Return type:
Return widget context menu – built using active tools
- Parameters:
plot – plot instance (default to None)
- Returns:
context menu
- Return type:
- update_tools_status(plot: BasePlot | None = None) None [source]¶
Update tools for current plot
- Parameters:
plot – plot instance (default to None)
- create_action(title: str, triggered: Callable | None = None, toggled: Callable | None = None, shortcut: QKeySequence | None = None, icon: QIcon | None = None, tip: str | None = None, checkable: bool | None = None, context: ShortcutContext = 1, enabled: bool | None = None)[source]¶
Create a new QAction
- Parameters:
parent (QWidget or None) – Parent widget
title (str) – Action title
triggered (Callable or None) – Triggered callback
toggled (Callable or None) – Toggled callback
shortcut (QKeySequence or None) – Shortcut
icon (QIcon or None) – Icon
tip (str or None) – Tooltip
checkable (bool or None) – Checkable
context (ShortcutContext) – Shortcut context
enabled (bool or None) – Enabled
- Returns:
New action
- Return type:
- register_standard_tools() None [source]¶
Registering basic tools for standard plot dialog –> top of the context-menu
- register_curve_annotation_tools() None [source]¶
Register all curve friendly annotation tools for the plot
- register_image_annotation_tools() None [source]¶
Register all image friendly annotation tools for the plot
- class plotpy.plot.PlotOptions(title: str | None = None, xlabel: str | tuple[str, str] | None = None, ylabel: str | tuple[str, str] | None = None, zlabel: str | None = None, xunit: str | tuple[str, str] | None = None, yunit: str | tuple[str, str] | None = None, zunit: str | None = None, yreverse: bool | None = None, aspect_ratio: float = 1.0, lock_aspect_ratio: bool | None = None, curve_antialiasing: bool | None = None, gridparam: GridParam | None = None, section: str = 'plot', type: str | PlotType = 'auto', axes_synchronised: bool = False, force_colorbar_enabled: bool = False, no_image_analysis_widgets: bool = False, show_contrast: bool = False, show_itemlist: bool = False, show_xsection: bool = False, show_ysection: bool = False, xsection_pos: str = 'top', ysection_pos: str = 'right')[source]¶
Plot options
- Parameters:
title – The plot title
xlabel – (bottom axis title, top axis title) or bottom axis title only
ylabel – (left axis title, right axis title) or left axis title only
zlabel – The Z-axis label
xunit – (bottom axis unit, top axis unit) or bottom axis unit only
yunit – (left axis unit, right axis unit) or left axis unit only
zunit – The Z-axis unit
yreverse – If True, the Y-axis is reversed
aspect_ratio – The plot aspect ratio
lock_aspect_ratio – If True, the aspect ratio is locked
curve_antialiasing – If True, the curve antialiasing is enabled
gridparam – The grid parameters
section – The plot configuration section name (“plot”, by default)
type – The plot type (“auto”, “manual”, “curve” or “image”)
axes_synchronised – If True, the axes are synchronised
force_colorbar_enabled – If True, the colorbar is always enabled
no_image_analysis_widgets – If True, the image analysis widgets are not added
show_contrast – If True, the contrast adjustment panel is visible
show_itemlist – If True, the itemlist panel is visible
show_xsection – If True, the X-axis cross section panel is visible
show_ysection – If True, the Y-axis cross section panel is visible
xsection_pos – The X-axis cross section panel position (“top” or “bottom”)
ysection_pos – The Y-axis cross section panel position (“left” or “right”)
- class plotpy.plot.PlotWidget(parent: QWidget | None = None, toolbar: bool = False, options: PlotOptions | dict[str, Any] | None = None, panels: tuple[PanelWidget] | None = None, auto_tools: bool = True)[source]¶
Plot widget with integrated plot manager, toolbar, tools and panels
- Parameters:
parent – Parent widget
toolbar – Show/hide toolbar
options – Plot options
panels – Additionnal panels
auto_tools – If True, the plot tools are automatically registered. If False, the user must register the tools manually.
- get_manager() PlotManager [source]¶
Return the plot manager
- Returns:
The plot widget manager
- class plotpy.plot.PlotDialog(parent: QWidget | None = None, toolbar: bool = False, options: PlotOptions | dict[str, Any] | None = None, panels: list[PanelWidget] | None = None, auto_tools: bool = True, title: str = 'PlotPy', icon: str = 'plotpy.svg', edit: bool = False, size: tuple[int, int] | None = None)[source]¶
Plotting dialog box with integrated plot manager
- Parameters:
parent – parent widget
toolbar – show/hide toolbar
options – plot options
panels – additionnal panels
auto_tools – If True, the plot tools are automatically registered. If False, the user must register the tools manually.
title – The window title
icon – The window icon
edit – If True, the plot is editable
size – The window size (width, height). Defaults to None (no resize)
- get_manager() PlotManager [source]¶
Return the plot manager
- Returns:
The plot widget manager
- setup_widget(toolbar: bool = False, options: PlotOptions | dict[str, Any] | None = None, panels: list[PanelWidget] | None = None, auto_tools: bool = False) None [source]¶
Setup the widget
- Parameters:
toolbar – If True, the plot toolbar is displayed
options – Plot options
panels – The panels to add to the plot
auto_tools – If True, the plot tools are automatically registered. If False, the user must register the tools manually.
- add_widget(widget: QWidget, row: int | None = None, column: int | None = None, rowspan: int | None = None, columnspan: int | None = None) None [source]¶
Add widget to the widget main layout
- Parameters:
widget – The widget to add
row – The row index
column – The column index
rowspan – The row span
columnspan – The column span
- install_button_layout() None [source]¶
Install standard buttons (OK, Cancel) in dialog button box layout
This method may be overriden to customize the button box
- class plotpy.plot.PlotWindow(parent: QWidget | None = None, toolbar: bool = False, options: PlotOptions | dict[str, Any] | None = None, panels: list[PanelWidget] | None = None, auto_tools: bool = True, title: str = 'PlotPy', icon: str = 'plotpy.svg', size: tuple[int, int] | None = None)[source]¶
Plotting window with integrated plot manager
- Parameters:
parent – parent widget
toolbar – show/hide toolbar
options – plot options
panels – additionnal panels
auto_tools – If True, the plot tools are automatically registered. If False, the user must register the tools manually.
title – The window title
icon – The window icon
size – The window size (width, height). Defaults to None (no resize)
- get_manager() PlotManager [source]¶
Return the plot manager
- Returns:
The plot widget manager
- setup_widget(toolbar: bool = False, options: PlotOptions | dict[str, Any] | None = None, panels: list[PanelWidget] | None = None, auto_tools: bool = False) None [source]¶
Setup the widget
- Parameters:
toolbar – If True, the plot toolbar is displayed
options – Plot options
panels – The panels to add to the plot
auto_tools – If True, the plot tools are automatically registered. If False, the user must register the tools manually.
- add_widget(widget: QWidget, row: int | None = None, column: int | None = None, rowspan: int | None = None, columnspan: int | None = None) None [source]¶
Add widget to the widget main layout
- Parameters:
widget – The widget to add
row – The row index
column – The column index
rowspan – The row span
columnspan – The column span
- register_tools()[source]¶
Register the plotting tools: the base implementation of this method register tools according to the plot type (curve, image, etc.)
This method may be overriden to provide a fully customized set of tools
- class plotpy.plot.SyncPlotWindow(parent: QWidget | None = None, toolbar: bool = True, options: PlotOptions | dict[str, Any] | None = None, auto_tools: bool = True, title: str = 'PlotPy', icon: str = 'plotpy.svg', size: tuple[int, int] | None = None)[source]¶
Window for showing plots, optionally synchronized
- Parameters:
parent – parent widget
toolbar – show/hide toolbar
options – plot options
panels – additionnal panels
auto_tools – If True, the plot tools are automatically registered. If False, the user must register the tools manually.
title – The window title
icon – The window icon
size – The window size (width, height). Defaults to None (no resize)
Usage: first, create a window, then add plots to it, then call the
SyncPlotWindow.finalize_configuration()
method to add panels and eventually register tools.Example:
from plotpy.plot import BasePlot, SyncPlotWindow win = SyncPlotWindow(title="My window") plot = BasePlot() win.add_plot(plot) win.finalize_configuration() win.show()
- get_manager() PlotManager [source]¶
Return the plot manager
- Returns:
The plot widget manager
Low-level features¶
- class plotpy.constants.PlotType(value)[source]¶
This is the enum used for the plot type. Defines how the plot should deal with the different PlotItems types (curves and images)
- AUTO = 1¶
Automatic plot type. The first PlotItem attached to the plot sets the type. All tools (curve and image related) are registered and accessible depending on the last selected PlotItem.
- CURVE = 2¶
Curve specialized plot. The y axis is not reversed and the aspect ratio is not locked by default. Only CURVE typed tools are automatically registered.
- IMAGE = 3¶
Image specialized plot. The y axis is reversed and the aspect ratio is locked by default. Only IMAGE typed tools are automatically registered.
- MANUAL = 4¶
No assumption is made on the type of items to be displayed on the plot. Acts like the CURVE value of the enum for y axis and aspect ratio. No tool are automatically registered.
- class plotpy.plot.BasePlot(parent: QWidget | None = None, options: BasePlotOptions | dict[str, Any] | None = None)[source]¶
Enhanced QwtPlot class providing methods for handling items and axes better
It distinguishes activatable items from basic QwtPlotItems.
Activatable items must support IBasePlotItem interface and should be added to the plot using add_item methods.
- Parameters:
parent – parent widget
options – plot options
- SIG_ITEM_MOVED(PyQt_PyObject, double, double, double, double)¶
Signal emitted by plot when an IBasePlotItem object was moved
- SIG_ITEM_HANDLE_MOVED(PyQt_PyObject)¶
Signal emitted by plot when an IBasePlotItem handle was moved
- Parameters:
item – the moved item
- SIG_ITEM_RESIZED(PyQt_PyObject, double, double)¶
Signal emitted by plot when an IBasePlotItem object was resized
- SIG_ITEM_ROTATED(PyQt_PyObject, double)¶
Signal emitted by plot when an IBasePlotItem object was rotated
- Parameters:
item – the rotated item
angle (float) – the new angle (in radians)
- SIG_MARKER_CHANGED(PyQt_PyObject)¶
Signal emitted by plot when a shape.Marker position changes
- Parameters:
marker – the moved marker
- SIG_AXES_CHANGED(PyQt_PyObject)¶
Signal emitted by plot when a shape.Axes position (or the angle) changes
- Parameters:
axes – the moved axes
- SIG_ANNOTATION_CHANGED(PyQt_PyObject)¶
Signal emitted by plot when an annotation.AnnotatedShape position changes
- Parameters:
annotation – the moved annotation
- SIG_RANGE_CHANGED(PyQt_PyObject, double, double)¶
Signal emitted by plot when the a shape.XRangeSelection range changes
- SIG_ITEMS_CHANGED(PyQt_PyObject)¶
Signal emitted by plot when item list has changed (item removed, added, …)
- Parameters:
plot – the plot
- SIG_ITEM_PARAMETERS_CHANGED(PyQt_PyObject)¶
Signal emitted by plot when item parameters have changed (through the item’s parameters dialog, or when setting colormap using the dedicated tool)
- Parameters:
item – the item
- SIG_AXIS_PARAMETERS_CHANGED(int)¶
Signal emitted by plot when axis parameters have changed (through the axis parameters dialog)
- Parameters:
axis_id – the axis id (0: left, 1: right, 2: bottom, 3: top)
- SIG_ACTIVE_ITEM_CHANGED(PyQt_PyObject)¶
Signal emitted by plot when selected item has changed
- Parameters:
plot – the plot
- SIG_ITEM_REMOVED(PyQt_PyObject)¶
Signal emitted by plot when an item was deleted from the item list or using the delete item tool
- Parameters:
item – the deleted item
- SIG_ITEM_SELECTION_CHANGED(PyQt_PyObject)¶
Signal emitted by plot when an item is selected
- Parameters:
item – the selected item
- SIG_PLOT_LABELS_CHANGED(PyQt_PyObject)¶
Signal emitted by plot when plot’s title or any axis label has changed
- Parameters:
plot – the plot
- SIG_AXIS_DIRECTION_CHANGED(PyQt_PyObject, PyQt_PyObject)¶
Signal emitted by plot when any plot axis direction has changed
- Parameters:
plot – the plot
axis_id – the axis id (“left”, “right”, “bottom”, “top”)
- SIG_LUT_CHANGED(PyQt_PyObject)¶
Signal emitted by plot when LUT has been changed by the user
- Parameters:
plot – the plot
- SIG_MASK_CHANGED(PyQt_PyObject)¶
Signal emitted by plot when image mask has changed
- Parameters:
plot – the plot
- SIG_CS_CURVE_CHANGED(PyQt_PyObject)¶
Signal emitted by cross section plot when cross section curve data has changed
- Parameters:
plot – the plot
- SIG_PLOT_AXIS_CHANGED(PyQt_PyObject)¶
Signal emitted by plot when plot axis has changed, e.g. when panning/zooming
- Parameters:
plot – the plot
- on_active_curve(x: float, y: float) tuple[float, float] [source]¶
Callback called when the active curve is moved
- do_move_marker(event: QMouseEvent) None [source]¶
Move the marker
- Parameters:
event (QMouseEvent) – the event
- do_pan_view(dx: tuple[float, float, float, float], dy: tuple[float, float, float, float], replot: bool = True) None [source]¶
Translate the active axes according to dx, dy axis ‘state’ tuples
- do_zoom_view(dx: tuple[float, float, float, float], dy: tuple[float, float, float, float], lock_aspect_ratio: bool | None = None, replot: bool = True) None [source]¶
Change the scale of the active axes (zoom/dezoom) according to dx, dy axis ‘state’ tuples
We try to keep initial pos fixed on the canvas as the scale changes
- do_zoom_rect_view(start: QPointF, end: QPointF) None [source]¶
Zoom to rectangle defined by start and end points
- get_default_item() IBasePlotItem | None [source]¶
Return default item, depending on plot’s default item type (e.g. for a curve plot, this is a curve item type).
Return nothing if there is more than one item matching the default item type.
- Returns:
the default item
- Return type:
- mouseDoubleClickEvent(event: QMouseEvent) None [source]¶
Reimplement QWidget method
- set_manager(manager: PlotManager, plot_id: int) None [source]¶
Set the associated
plot.manager.PlotManager
instance- Parameters:
manager (PlotManager) – the manager
plot_id (int) – the plot id
- get_axis_id(axis_name: str | int) int [source]¶
Return axis ID from axis name If axis ID is passed directly, check the ID
- read_axes_styles(section: str, options: list[str, str, str, str]) None [source]¶
Read axes styles from section and options (one option for each axis in the order left, right, bottom, top)
Skip axis if option is None
- update_axis_style(axis_id: int) None [source]¶
Update axis style
- Parameters:
axis_id (int) – the axis id
- get_axis_limits(axis_id: int) tuple[float, float] [source]¶
Return axis limits (minimum and maximum values)
- set_axis_limits(axis_id: int, vmin: float, vmax: float, stepsize: int = 0) None [source]¶
Set axis limits (minimum and maximum values) and step size
- set_axis_ticks(axis_id: int, nmajor: int | None = None, nminor: int | None = None) None [source]¶
Set axis maximum number of major ticks and maximum of minor ticks
- get_axis_scale(axis_id: int) str [source]¶
Return the name (‘lin’ or ‘log’) of the scale used by axis
- set_axis_scale(axis_id: int, scale: str, autoscale: bool = True) None [source]¶
Set axis scale
- Parameters:
Example
self.set_axis_scale(curve.yAxis(), ‘lin’)
- get_scales() tuple[str, str] [source]¶
Return active curve scales
Example
self.get_scales() -> (‘lin’, ‘lin’)
- set_scales(xscale: str, yscale: str) None [source]¶
Set active curve scales
- Parameters:
Example
self.set_scales(‘lin’, ‘lin’)
- enable_used_axes()[source]¶
Enable only used axes For now, this is needed only by the pyplot interface
- get_items(z_sorted: bool = False, item_type: type[IItemType | IBasePlotItem] | None = None) list[IBasePlotItem] [source]¶
Return widget’s item list (items are based on IBasePlotItem’s interface)
- Parameters:
- Returns:
the item list
- Return type:
- get_public_items(z_sorted: bool = False, item_type: IBasePlotItem | None = None) list[IBasePlotItem] [source]¶
Return widget’s public item list (items are based on IBasePlotItem’s interface)
- Parameters:
- Returns:
the item list
- Return type:
- get_private_items(z_sorted: bool = False, item_type: IBasePlotItem | None = None) list[IBasePlotItem] [source]¶
Return widget’s private item list (items are based on IBasePlotItem’s interface)
- Parameters:
- Returns:
the item list
- Return type:
- save_widget(fname: str) None [source]¶
Grab widget’s window and save it to filename (/.png, /.pdf)
- Parameters:
fname (str) – the filename
- get_selected_items(z_sorted=False, item_type: IBasePlotItem | None = None) list[IBasePlotItem] [source]¶
Return selected items
- Parameters:
- Returns:
the selected items
- Return type:
- get_max_z() int [source]¶
Return maximum z-order for all items registered in plot If there is no item, return 0
- Returns:
the maximum z-order
- Return type:
- add_item(item: IBasePlotItem, z: int | None = None, autoscale: bool = True) None [source]¶
Add a plot item instance to this plot widget
- Parameters:
item (IBasePlotItem) – the item
z (int) – the z order (optional, default=None)
autoscale (bool) – autoscale the plot (optional, default=True)
- add_item_with_z_offset(item: IBasePlotItem, zoffset: int) None [source]¶
Add a plot item instance within a specified z range, over an offset
- Parameters:
item (IBasePlotItem) – the item
zoffset (int) – the z offset
- del_items(items: list[IBasePlotItem]) None [source]¶
Remove item from widget
- Parameters:
items (list[IBasePlotItem]) – the items
- del_item(item: IBasePlotItem) None [source]¶
Remove item from widget Convenience function (see ‘del_items’)
- Parameters:
item (IBasePlotItem) – the item
- set_item_visible(item: IBasePlotItem, state: bool, notify: bool = True, replot: bool = True) None [source]¶
Show/hide item and emit a SIG_ITEMS_CHANGED signal
- Parameters:
item (IBasePlotItem) – the item
state (bool) – the visibility state
notify (bool) – notify the item list (optional, default=True)
replot (bool) – replot the widget (optional, default=True)
- show_items(items: list[IBasePlotItem] | None = None, item_type: IBasePlotItem | None = None) None [source]¶
Show items (if items is None, show all items)
- Parameters:
items (list[IBasePlotItem]) – the items (optional, default=None)
item_type (IBasePlotItem) – the item type (optional, default=None)
- hide_items(items: list[IBasePlotItem] | None = None, item_type: IBasePlotItem | None = None) None [source]¶
Hide items (if items is None, hide all items)
- Parameters:
items (list[IBasePlotItem]) – the items (optional, default=None)
item_type (IBasePlotItem) – the item type (optional, default=None)
- save_items(iofile: str | IO[str], selected: bool = False) None [source]¶
Save (serializable) items to file using the
pickle
protocol- Parameters:
See also
BasePlot.restore_items()
- restore_items(iofile: str | IO[str]) None [source]¶
Restore items from file using the
pickle
protocolSee also
BasePlot.save_items()
- serialize(writer: guidata.io.HDF5Writer | guidata.io.INIWriter | guidata.io.JSONWriter) None [source]¶
Serialize object to HDF5 writer
- Parameters:
writer – HDF5, INI or JSON writer
See also
BasePlot.restore_items()
- deserialize(reader: guidata.io.HDF5Reader | guidata.io.INIReader | guidata.io.JSONReader) None [source]¶
Deserialize object from HDF5 reader
- Parameters:
reader – HDF5, INI or JSON reader
See also
BasePlot.save_items()
- set_items(*args: IBasePlotItem) None [source]¶
Utility function used to quickly setup a plot with a set of items
- Parameters:
args – the items
Example
self.set_items(item1, item2, item3)
- del_all_items(except_grid: bool = True) None [source]¶
Del all items, eventually (default) except grid
- Parameters:
except_grid (bool) – if True, don’t delete grid (optional, default=True)
- move_up(item_list: list[IBasePlotItem] | IBasePlotItem) bool [source]¶
Move item(s) up, i.e. to the foreground (swap item with the next item in z-order)
- Parameters:
item_list (list[IBasePlotItem] | IBasePlotItem) – the item(s)
- Returns:
True if items have been moved effectively
- Return type:
- move_down(item_list: list[IBasePlotItem] | IBasePlotItem) bool [source]¶
Move item(s) down, i.e. to the background (swap item with the previous item in z-order)
- Parameters:
item_list (list[IBasePlotItem] | IBasePlotItem) – the item(s)
- Returns:
True if items have been moved effectively
- Return type:
- set_items_readonly(state: bool) None [source]¶
Set all items readonly state to state Default item’s readonly state: False (items may be deleted)
- Parameters:
state (bool) – the readonly state
- select_item(item: IBasePlotItem) None [source]¶
Select item
- Parameters:
item (IBasePlotItem) – the item
- unselect_item(item: IBasePlotItem) None [source]¶
Unselect item
- Parameters:
item (IBasePlotItem) – the item
- get_last_active_item(item_type: type[IItemType]) IBasePlotItem | None [source]¶
Return last active item corresponding to passed item_type
- Parameters:
item_type (IItemType) – the item type
- Returns:
the item
- Return type:
- select_some_items(items: list[IBasePlotItem]) None [source]¶
Select items
- Parameters:
items (list[IBasePlotItem]) – the items
- set_active_item(item: IBasePlotItem, select: bool = True) None [source]¶
Set active item, and unselect the old active item. For CurveItems, the grid axes are changed according to the selected item
- Parameters:
item – the item
select – select item after setting it as active (optional, default=True)
- get_active_item(force: bool = False) IBasePlotItem | None [source]¶
Return active item Force item activation if there is no active item
- Parameters:
force (bool) – force item activation (optional, default=False)
- Returns:
the active item or None
- Return type:
- get_nearest_object(pos: QPointF, close_dist: int = 0) tuple[IBasePlotItem | None, float, int | None, bool] [source]¶
Return nearest item from position ‘pos’
- Parameters:
- Returns:
the nearest item
- Return type:
tuple[IBasePlotItem | None, float, int | None, bool]
If close_dist > 0:
Return the first found item (higher z) which distance to ‘pos’ is less than close_dist
else:
Return the closest item
- get_nearest_object_in_z(pos: QPointF) tuple[IBasePlotItem | None, int, bool | None, int | None] [source]¶
Return nearest item for which position ‘pos’ is inside of it (iterate over items with respect to their ‘z’ coordinate)
Return widget context menu
- Returns:
the context menu
- Return type:
- get_plot_parameters_status(key: str) bool [source]¶
Return True if the plot parameters are available
- get_selected_item_parameters(itemparams: ItemParameters) None [source]¶
Return a list of DataSets for selected items parameters the datasets will be edited and passed back to set_plot_parameters
- Parameters:
itemparams (ItemParameters) – the item parameters
- get_axesparam_class(item: IBasePlotItem) AxesParam [source]¶
Return AxesParam dataset class associated to item’s type
- Parameters:
item (IBasePlotItem) – the item
- Returns:
the AxesParam dataset class
- Return type:
- get_plot_parameters(key: str, itemparams: ItemParameters) None [source]¶
Return a list of DataSets for a given parameter key the datasets will be edited and passed back to set_plot_parameters
this is a generic interface to help building context menus using the BasePlotMenuTool
- Parameters:
key (str) – the parameter key
itemparams (ItemParameters) – the item parameters
- set_item_parameters(itemparams: ItemParameters) None [source]¶
Set item (plot, here) parameters
- Parameters:
itemparams (ItemParameters) – the item parameters
- edit_plot_parameters(key: str) None [source]¶
Edit plot parameters
- Parameters:
key (str) – the parameter key
- edit_axis_parameters(axis_id: int) None [source]¶
Edit axis parameters
- Parameters:
axis_id (int) – the axis ID
- add_autoscale_excludes(items: list[IBasePlotItem]) None [source]¶
Add items to autoscale excludes list
- Parameters:
items (list[IBasePlotItem]) – the items
- remove_autoscale_excludes(items: list[IBasePlotItem]) None [source]¶
Remove items from autoscale excludes list
- Parameters:
items (list[IBasePlotItem]) – the items
- get_auto_scale_excludes() list[IBasePlotItem] [source]¶
Return autoscale excludes
- Returns:
the items
- Return type:
- do_autoscale(replot: bool = True, axis_id: int | None = None) None [source]¶
Do autoscale on all axes
- disable_autoscale() None [source]¶
Re-apply the axis scales so as to disable autoscaling without changing the view
- invalidate() None [source]¶
Invalidate paint cache and schedule redraw use instead of replot when only the content of the canvas needs redrawing (axes, shouldn’t change)
- get_axis_direction(axis_id: int | str) bool [source]¶
Return axis direction of increasing values
- Parameters:
axis_id – axis id (constants.Y_LEFT, constants.X_BOTTOM, …) or string: ‘bottom’, ‘left’, ‘top’ or ‘right’
- Returns:
False (default)
- set_axis_direction(axis_id: int | str, reverse: bool = False) None [source]¶
Set axis direction of increasing values
- Parameters:
axis_id – axis id (constants.Y_LEFT, constants.X_BOTTOM, …) or string: ‘bottom’, ‘left’, ‘top’ or ‘right’
reverse (bool) – False (default)
If reverse is False:
x-axis values increase from left to right
y-axis values increase from bottom to top
If reverse is True:
x-axis values increase from right to left
y-axis values increase from top to bottom
- set_titles(title: str | None = None, xlabel: str | tuple[str, str] | None = None, ylabel: str | tuple[str, str] | None = None, xunit: str | tuple[str, str] | None = None, yunit: str | tuple[str, str] | None = None) None [source]¶
Set plot and axes titles at once
- Parameters:
title (str) – plot title
xlabel (str | tuple[str, str]) – (bottom axis title, top axis title) or bottom axis title only
ylabel (str | tuple[str, str]) – (left axis title, right axis title) or left axis title only
xunit (str | tuple[str, str]) – (bottom axis unit, top axis unit) or bottom axis unit only
yunit (str | tuple[str, str]) – (left axis unit, right axis unit) or left axis unit only
- set_pointer(pointer_type: str | None) None [source]¶
Set pointer.
- Parameters:
pointer_type (str) – pointer type (None, ‘canvas’, ‘curve’)
Meaning of pointer_type:
None: disable pointer
‘canvas’: enable canvas pointer
‘curve’: enable on-curve pointer
- set_antialiasing(checked: bool) None [source]¶
Toggle curve antialiasing
- Parameters:
checked (bool) – True to enable antialiasing
- set_plot_limits(x0: float, x1: float, y0: float, y1: float, xaxis: str | int = 'bottom', yaxis: str | int = 'left') None [source]¶
Set plot scale limits
- get_plot_limits(xaxis: str | int = 'bottom', yaxis: str | int = 'left') tuple[float, float, float, float] [source]¶
Return plot scale limits
- get_current_aspect_ratio() float | None [source]¶
Return current aspect ratio
- Returns:
The current aspect ratio or None if the aspect ratio cannot be computed (this happens when the plot has been shrunk to a size so that the width is zero)
- set_aspect_ratio(ratio: float | None = None, lock: bool | None = None) None [source]¶
Set aspect ratio
- apply_aspect_ratio(full_scale: bool = False) None [source]¶
Apply aspect ratio
- Parameters:
full_scale – if True, the aspect ratio is applied to the full scale (this argument is True only when doing autoscale, i.e. in method
do_autoscale()
: it is necessary to ensure that the whole image items are visible after autoscale, whatever their aspect ratio)
- update_colormap_axis(item: IColormapImageItemType) None [source]¶
Update colormap axis
- Parameters:
item (IColormapImageItemType) – the item
- classmethod register_autoscale_type(type_)[source]¶
Add type_ to the list of types used to check if an item is taken into account to compute the scale.
Class must defines the following methods:
is_empty(): returns True if the item is empty
boundingRect(): returns the bouding rect as a QRectF
isVisible(): returns True if item is visible
xAxis() and yAxis()
- class plotpy.plot.BasePlotOptions(title: str | None = None, xlabel: str | tuple[str, str] | None = None, ylabel: str | tuple[str, str] | None = None, zlabel: str | None = None, xunit: str | tuple[str, str] | None = None, yunit: str | tuple[str, str] | None = None, zunit: str | None = None, yreverse: bool | None = None, aspect_ratio: float = 1.0, lock_aspect_ratio: bool | None = None, curve_antialiasing: bool | None = None, gridparam: GridParam | None = None, section: str = 'plot', type: str | PlotType = 'auto', axes_synchronised: bool = False, force_colorbar_enabled: bool = False)[source]¶
Base plot options
- Parameters:
title – The plot title
xlabel – (bottom axis title, top axis title) or bottom axis title only
ylabel – (left axis title, right axis title) or left axis title only
zlabel – The Z-axis label
xunit – (bottom axis unit, top axis unit) or bottom axis unit only
yunit – (left axis unit, right axis unit) or left axis unit only
zunit – The Z-axis unit
yreverse – If True, the Y-axis is reversed
aspect_ratio – The plot aspect ratio
lock_aspect_ratio – If True, the aspect ratio is locked
curve_antialiasing – If True, the curve antialiasing is enabled
gridparam – The grid parameters
section – The plot configuration section name (“plot”, by default)
type – The plot type (“auto”, “manual”, “curve” or “image”)
axes_synchronised – If True, the axes are synchronised
force_colorbar_enabled – If True, the colorbar is always enabled