Reference

Base classes

class plotpy.interfaces.IItemType[source]

Item types are used to categorized items in a broader way than objects obeying IBasePlotItem.

The necessity arises from the fact that Plotpy Items can inherit from different base classes and still provide functionalities akin to a given ItemType

the types() method of an item returns a list of interfaces this item supports

class plotpy.interfaces.IBasePlotItem[source]

This is the interface that QwtPlotItem objects must implement to be handled by BasePlot widgets

class plotpy.interfaces.IColormapImageItemType[source]

An image with an associated colormap

Curves

class plotpy.items.CurveItem(curveparam: CurveParam | None = None)[source]

Curve item

Parameters:

curveparam – Curve parameters

boundingRect() QRectF[source]

Return the bounding rectangle of the data

Returns:

Bounding rectangle of the data

types() tuple[type[IItemType], ...][source]

Returns a group or category for this item. This should be a tuple of class objects inheriting from IItemType

Returns:

Tuple of class objects inheriting from IItemType

Return type:

tuple

set_selectable(state: bool) None[source]

Set item selectable state

Parameters:

state – True if item is selectable, False otherwise

set_resizable(state: bool) None[source]

Set item resizable state (or any action triggered when moving an handle, e.g. rotation)

Parameters:

state – True if item is resizable, False otherwise

set_movable(state: bool) None[source]

Set item movable state

Parameters:

state – True if item is movable, False otherwise

set_rotatable(state: bool) None[source]

Set item rotatable state

Parameters:

state – True if item is rotatable, False otherwise

can_select() bool[source]

Returns True if this item can be selected

Returns:

True if item can be selected, False otherwise

Return type:

bool

can_resize() bool[source]

Returns True if this item can be resized

Returns:

True if item can be resized, False otherwise

Return type:

bool

can_rotate() bool[source]

Returns True if this item can be rotated

Returns:

True if item can be rotated, False otherwise

Return type:

bool

can_move() bool[source]

Returns True if this item can be moved

Returns:

True if item can be moved, False otherwise

Return type:

bool

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

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

set_readonly(state: bool) None[source]

Set object readonly state

Parameters:

state – True if object is readonly, False otherwise

is_readonly() bool[source]

Return object readonly state

Returns:

True if object is readonly, False otherwise

Return type:

bool

set_private(state: bool) None[source]

Set object as private

Parameters:

state – True if object is private, False otherwise

is_private() bool[source]

Return True if object is private

Returns:

True if object is private, False otherwise

Return type:

bool

invalidate_plot() None[source]

Invalidate the plot to force a redraw

select() None[source]

Select the object and eventually change its appearance to highlight the fact that it’s selected

unselect() None[source]

Unselect the object and eventually restore its original appearance to highlight the fact that it’s not selected anymore

get_data() tuple[ndarray, ndarray][source]

Return curve data x, y (NumPy arrays)

Returns:

Tuple with two elements: x and y NumPy arrays

Return type:

tuple

update_data() None[source]

Update curve data with current arrays.

dsamp(data: ndarray) ndarray[source]

Downsample data

Parameters:

data – Data to downsample

Returns:

Downsampled data

set_data(x: ndarray, y: ndarray) None[source]

Set curve data

Parameters:
  • x – X data

  • y – Y data

  • decimated_data – Set to True if CurveItem X and Y arrays are already set and this method is called to update decimated data (i.e. only update 1/N value with N set in CurveItem.param.decimation).

is_empty() bool[source]

Return True if the item is empty

Returns:

True if the item is empty, False otherwise

hit_test(pos: QPointF) tuple[float, float, bool, None][source]

Return a tuple (distance, attach point, inside, other_object)

Parameters:

pos – Position

Returns:

Tuple with four elements: (distance, attach point, inside,

other_object).

Return type:

tuple

Description of the returned values:

  • distance: distance in pixels (canvas coordinates) to the closest

    attach point

  • attach point: handle of the attach point

  • inside: True if the mouse button has been clicked inside the object

  • other_object: if not None, reference of the object which will be

    considered as hit instead of self

get_closest_coordinates(x: float, y: float) tuple[float, float][source]

Get the closest coordinates to the given point

Parameters:
  • x – X coordinate

  • y – Y coordinate

Returns:

Closest coordinates

Return type:

tuple[float, float]

get_coordinates_label(x: float, y: float) str[source]

Get the coordinates label for the given coordinates

Parameters:
  • x – X coordinate

  • y – Y coordinate

Returns:

Coordinates label

Return type:

str

get_closest_x(xc: float) tuple[float, float][source]

Get the closest point to the given x coordinate

Parameters:

xc – X coordinate

Returns:

Closest point coordinates

Return type:

tuple[float, float]

move_local_point_to(handle: int, pos: QPointF, ctrl: bool = None) None[source]

Move a handle as returned by hit_test to the new position

Parameters:
  • handle – Handle

  • pos – Position

  • ctrl – True if <Ctrl> button is being pressed, False otherwise

move_local_shape(old_pos: QPointF, new_pos: QPointF) None[source]

Translate the shape such that old_pos becomes new_pos in canvas coordinates

Parameters:
  • old_pos – Old position

  • new_pos – New position

move_with_selection(delta_x: float, delta_y: float) None[source]

Translate the item together with other selected items

Parameters:
  • delta_x – Translation in plot coordinates along x-axis

  • delta_y – Translation in plot coordinates along y-axis

update_params()[source]

Update item parameters (object properties) from datasets

update_item_parameters() None[source]

Update item parameters (dataset) from object properties

get_item_parameters(itemparams: ItemParameters) None[source]

Appends datasets to the list of DataSets describing the parameters used to customize apearance of this item

Parameters:

itemparams – Item parameters

set_item_parameters(itemparams: ItemParameters) None[source]

Change the appearance of this item according to the parameter set provided

Parameters:

itemparams – Item parameters

class plotpy.items.ErrorBarCurveItem(curveparam: CurveParam | None = None, errorbarparam: ErrorBarParam | None = None)[source]

Error-bar curve item

Parameters:
  • curveparam – Curve parameters

  • errorbarparam – Error-bar parameters

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

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

unselect() None[source]

Unselect the object and eventually restore its original appearance to highlight the fact that it’s not selected anymore

get_data() tuple[ndarray, ndarray, ndarray, ndarray][source]

Get data

Returns:

Data as a tuple (x, y, dx, dy)

set_data(x: ndarray, y: ndarray, dx: ndarray | float | None = None, dy: ndarray | float | None = None) None[source]

Set data

Parameters:
  • x – X data

  • y – Y data

  • dx – X error data

  • dy – Y error data

get_minmax_arrays(all_values: bool = True) tuple[ndarray[float], ndarray[float], ndarray[float], ndarray[float]][source]

Get min/max arrays

Parameters:

all_values – If True, return all values, else return only finite values

Returns:

Min/max arrays

get_closest_coordinates(x: float, y: float) tuple[float, float][source]

Get the closest coordinates to the given point

Parameters:
  • x – X coordinate

  • y – Y coordinate

Returns:

Closest coordinates

Return type:

tuple[float, float]

boundingRect() QRectF[source]

Return the bounding rectangle of the data

Returns:

Bounding rectangle of the data

draw(painter: QPainter, xMap: QwtScaleMap, yMap: QwtScaleMap, canvasRect: QRectF) None[source]

Draw the item

Parameters:
  • painter – Painter

  • xMap – X axis scale map

  • yMap – Y axis scale map

  • canvasRect – Canvas rectangle

update_params()[source]

Update object properties from item parameters

update_item_parameters() None[source]

Update item parameters (dataset) from object properties

get_item_parameters(itemparams: ItemParameters) None[source]

Appends datasets to the list of DataSets describing the parameters used to customize apearance of this item

Parameters:

itemparams – Item parameters

set_item_parameters(itemparams: ItemParameters) None[source]

Change the appearance of this item according to the parameter set provided

Parameters:

itemparams – Item parameters

Images

class plotpy.items.BaseImageItem(data: ndarray | None = None, param: Any | None = None)[source]

Base class for image items

Parameters:
  • data – Image data

  • param – Image parameters

get_default_param() Any[source]

Return instance of the default image param DataSet

set_filename(fname: str) None[source]

Set the filename of the image

Parameters:

fname – Filename

get_filename() str | None[source]

Get the filename of the image

Returns:

Filename

get_filter(filterobj, filterparam)[source]

Provides a filter object over this image’s content

get_pixel_coordinates(xplot: float, yplot: float) tuple[float, float][source]

Get pixel coordinates from plot coordinates

Parameters:
  • xplot – X plot coordinate

  • yplot – Y plot coordinate

Returns:

Pixel coordinates

get_plot_coordinates(xpixel: float, ypixel: float) tuple[float, float][source]

Get plot coordinates from pixel coordinates

Parameters:
  • xpixel – X pixel coordinate

  • ypixel – Y pixel coordinate

Returns:

Plot coordinates

get_closest_indexes(x: float, y: float, corner: str | None = None) tuple[int, int][source]

Get closest image pixel indexes to the given coordinates

Parameters:
  • x – X coordinate

  • y – Y coordinate

  • corner – None (not a corner), ‘TL’ (top-left corner), ‘BR’ (bottom-right corner)

Returns:

Closest image pixel indexes

get_closest_index_rect(x0: float, y0: float, x1: float, y1: float) tuple[int, int, int, int][source]

Get closest image rectangular pixel area index bounds

Parameters:
  • x0 – X coordinate of first point

  • y0 – Y coordinate of first point

  • x1 – X coordinate of second point

  • y1 – Y coordinate of second point

Returns:

Closest image rectangular pixel area index bounds

Note

Avoid returning empty rectangular area (return 1x1 pixel area instead). Handle reversed/not-reversed Y-axis orientation.

align_rectangular_shape(shape: RectangleShape) None[source]

Align rectangular shape to image pixels

Parameters:

shape – Shape to align

get_closest_pixel_indexes(x: float, y: float) tuple[int, int][source]

Get closest pixel indexes

Parameters:
  • x – X coordinate

  • y – Y coordinate

Returns:

Closest pixel indexes

Note

Instead of returning indexes of an image pixel like the method ‘get_closest_indexes’, this method returns the indexes of the closest pixel which is not necessarily on the image itself (i.e. indexes may be outside image index bounds: negative or superior than the image dimension)

Note

This is not the same as retrieving the canvas pixel coordinates (which depends on the zoom level)

get_x_values(i0: int, i1: int) ndarray[source]

Get X values from pixel indexes

Parameters:
  • i0 – First index

  • i1 – Second index

Returns:

X values corresponding to the given pixel indexes

get_y_values(j0: int, j1: int) ndarray[source]

Get Y values from pixel indexes

Parameters:
  • j0 – First index

  • j1 – Second index

Returns:

Y values corresponding to the given pixel indexes

get_r_values(i0, i1, j0, j1, flag_circle=False)[source]

Get radial values from pixel indexes

Parameters:
  • i0 – First index

  • i1 – Second index

  • j0 – Third index

  • j1 – Fourth index

  • flag_circle – Flag circle (Default value = False)

Returns:

Radial values corresponding to the given pixel indexes

set_data(data: ndarray, lut_range: tuple[float, float] | None = None) None[source]

Set image data

Parameters:
  • data – 2D NumPy array

  • lut_range – LUT range – tuple (levelmin, levelmax) (Default value = None)

get_data(x0: float, y0: float, x1: float | None = None, y1: float | None = None) float | tuple[ndarray, ndarray, ndarray][source]

Get image data

Parameters:
  • x0 – X coordinate of first point

  • y0 – Y coordinate of first point

  • x1 – X coordinate of second point (Default value = None)

  • y1 – Y coordinate of second point (Default value = None)

Returns:

Image level, or image levels in rectangular area (x0,y0,x1,y1)

as a tuple (x, y, data) of arrays

get_closest_coordinates(x: float, y: float) tuple[float, float][source]

Get the closest coordinates to the given point

Parameters:
  • x – X coordinate

  • y – Y coordinate

Returns:

Closest coordinates

Return type:

tuple[float, float]

get_coordinates_label(x: float, y: float) str[source]

Get the coordinates label for the given coordinates

Parameters:
  • x – X coordinate

  • y – Y coordinate

Returns:

Coordinates label

Return type:

str

set_background_color(qcolor: QColor | str) None[source]

Set background color

Parameters:

qcolor – Background color

set_color_map(name_or_table: str | EditableColormap, invert: bool | None = None) None[source]

Set colormap

Parameters:
  • name_or_table – Colormap name or colormap

  • invert – True to invert colormap, False otherwise (Default value = None, i.e. do not change the default behavior)

get_color_map() EditableColormap | None[source]

Get colormap

Returns:

Colormap

set_interpolation(interp_mode: int, size: int | None = None) None[source]

Set interpolation mode

Parameters:
  • interp_mode – INTERP_NEAREST, INTERP_LINEAR, INTERP_AA

  • size – (for anti-aliasing only) AA matrix size (Default value = None)

get_interpolation() tuple[int] | tuple[int, ndarray][source]

Get interpolation mode

set_lut_range(lut_range: tuple[float, float]) None[source]

Set the current active lut range

Parameters:

lut_range – Lut range, tuple(min, max)

Example

>>> item.set_lut_range((0.0, 1.0))
get_lut_range() tuple[float, float][source]

Get the current active lut range

Returns:

Lut range, tuple(min, max)

Return type:

tuple[float, float]

set_lut_threshold(threshold: float) None[source]

Set lut threshold value, eliminating the given percent of the histogram

Parameters:

threshold – Lut threshold value

get_lut_range_full() tuple[float, float][source]

Return full dynamic range

Returns:

Lut range, tuple(min, max)

Return type:

tuple[float, float]

get_lut_range_max() tuple[float, float][source]

Get maximum range for this dataset

Returns:

Lut range, tuple(min, max)

Return type:

tuple[float, float]

update_bounds() None[source]

Update image bounds to fit image shape

update_border() None[source]

Update image border rectangle to fit image shape

draw_border(painter: QPainter, xMap: qwt.scale_map.QwtScaleMap, yMap: qwt.scale_map.QwtScaleMap, canvasRect: QRectF) None[source]

Draw image border rectangle

Parameters:
  • painter – Painter

  • xMap – X axis scale map

  • yMap – Y axis scale map

  • canvasRect – Canvas rectangle

draw_image(painter: QPainter, canvasRect: QRectF, src_rect: tuple[float, float, float, float], dst_rect: tuple[float, float, float, float], xMap: qwt.scale_map.QwtScaleMap, yMap: qwt.scale_map.QwtScaleMap) None[source]

Draw image

Parameters:
  • painter – Painter

  • canvasRect – Canvas rectangle

  • src_rect – Source rectangle

  • dst_rect – Destination rectangle

  • xMap – X axis scale map

  • yMap – Y axis scale map

export_roi(src_rect: tuple[float, float, float, float], dst_rect: tuple[float, float, float, float], dst_image: ndarray, apply_lut: bool = False, apply_interpolation: bool = False, original_resolution: bool = False, force_interp_mode: str | None = None, force_interp_size: int | None = None) None[source]

Export a rectangular area of the image to another image

Parameters:
  • src_rect – Source rectangle

  • dst_rect – Destination rectangle

  • dst_image – Destination image

  • apply_lut – Apply lut (Default value = False)

  • apply_interpolation – Apply interpolation (Default value = False)

  • original_resolution – Original resolution (Default value = False)

  • force_interp_mode – Force interpolation mode (Default value = None)

  • force_interp_size – Force interpolation size (Default value = None)

draw(painter: QPainter, xMap: qwt.scale_map.QwtScaleMap, yMap: qwt.scale_map.QwtScaleMap, canvasRect: QRectF) None[source]

Draw the item

Parameters:
  • painter – Painter

  • xMap – X axis scale map

  • yMap – Y axis scale map

  • canvasRect – Canvas rectangle

boundingRect() QRectF[source]

Return the bounding rectangle of the data

Returns:

Bounding rectangle of the data

notify_new_offscreen() None[source]

Notify that the offscreen image has changed

setVisible(enable: bool) None[source]

Set item visibility

Parameters:

enable – True if item is visible, False otherwise

types() tuple[type[IItemType], ...][source]

Returns a group or category for this item. This should be a tuple of class objects inheriting from IItemType

Returns:

Tuple of class objects inheriting from IItemType

Return type:

tuple

set_readonly(state: bool) None[source]

Set object readonly state

Parameters:

state – True if object is readonly, False otherwise

is_readonly() bool[source]

Return object readonly state

Returns:

True if object is readonly, False otherwise

Return type:

bool

set_private(state: bool) None[source]

Set object as private

Parameters:

state – True if object is private, False otherwise

is_private() bool[source]

Return True if object is private

Returns:

True if object is private, False otherwise

Return type:

bool

select() None[source]

Select the object and eventually change its appearance to highlight the fact that it’s selected

unselect() None[source]

Unselect the object and eventually restore its original appearance to highlight the fact that it’s not selected anymore

is_empty() bool[source]

Return True if the item is empty

Returns:

True if the item is empty, False otherwise

set_selectable(state: bool) None[source]

Set item selectable state

Parameters:

state – True if item is selectable, False otherwise

set_resizable(state: bool) None[source]

Set item resizable state (or any action triggered when moving an handle, e.g. rotation)

Parameters:

state – True if item is resizable, False otherwise

set_movable(state: bool) None[source]

Set item movable state

Parameters:

state – True if item is movable, False otherwise

set_rotatable(state: bool) None[source]

Set item rotatable state

Parameters:

state – True if item is rotatable, False otherwise

can_select() bool[source]

Returns True if this item can be selected

Returns:

True if item can be selected, False otherwise

Return type:

bool

can_resize() bool[source]

Returns True if this item can be resized

Returns:

True if item can be resized, False otherwise

Return type:

bool

can_move() bool[source]

Returns True if this item can be moved

Returns:

True if item can be moved, False otherwise

Return type:

bool

can_rotate() bool[source]

Returns True if this item can be rotated

Returns:

True if item can be rotated, False otherwise

Return type:

bool

hit_test(pos: QPointF) tuple[float, float, bool, None][source]

Return a tuple (distance, attach point, inside, other_object)

Parameters:

pos – Position

Returns:

Tuple with four elements: (distance, attach point, inside,

other_object).

Return type:

tuple

Description of the returned values:

  • distance: distance in pixels (canvas coordinates) to the closest

    attach point

  • attach point: handle of the attach point

  • inside: True if the mouse button has been clicked inside the object

  • other_object: if not None, reference of the object which will be

    considered as hit instead of self

update_item_parameters() None[source]

Update item parameters (dataset) from object properties

get_item_parameters(itemparams: ItemParameters) None[source]

Appends datasets to the list of DataSets describing the parameters used to customize apearance of this item

Parameters:

itemparams – Item parameters

set_item_parameters(itemparams: ItemParameters) None[source]

Change the appearance of this item according to the parameter set provided

Parameters:

itemparams – Item parameters

move_local_point_to(handle: int, pos: QPointF, ctrl: bool = None) None[source]

Move a handle as returned by hit_test to the new position

Parameters:
  • handle – Handle

  • pos – Position

  • ctrl – True if <Ctrl> button is being pressed, False otherwise

move_local_shape(old_pos: QPointF, new_pos: QPointF) None[source]

Translate the shape such that old_pos becomes new_pos in canvas coordinates

Parameters:
  • old_pos – Old position

  • new_pos – New position

move_with_selection(delta_x: float, delta_y: float) None[source]

Translate the item together with other selected items

Parameters:
  • delta_x – Translation in plot coordinates along x-axis

  • delta_y – Translation in plot coordinates along y-axis

resize_with_selection(zoom_dx, zoom_dy)[source]

Resize the shape together with other selected items zoom_dx, zoom_dy : zoom factor for dx and dy

rotate_with_selection(angle)[source]

Rotate the shape together with other selected items angle : rotation angle

can_sethistogram() bool[source]

Returns True if this item can be associated with a levels histogram

Returns:

True if item can be associated with a levels histogram,

False otherwise

Return type:

bool

get_histogram(nbins: int, drange: tuple[float, float] | None = None) tuple[ndarray, ndarray][source]

Return a tuple (hist, bins) where hist is a list of histogram values

Parameters:
  • nbins – number of bins

  • drange – lower and upper range of the bins. If not provided, range is simply (data.min(), data.max()). Values outside the range are ignored.

Returns:

Tuple (hist, bins)

get_stats(x0: float, y0: float, x1: float, y1: float, show_surface: bool = False, show_integral: bool = False) str[source]

Return formatted string with stats on image rectangular area (output should be compatible with AnnotatedShape.get_infos)

Parameters:
  • x0 – X0

  • y0 – Y0

  • x1 – X1

  • y1 – Y1

  • show_surface – Show surface (Default value = False)

  • show_integral – Show integral (Default value = False)

get_xsection(y0: float | int, apply_lut: bool = False) ndarray[source]

Return cross section along x-axis at y=y0

Parameters:
  • y0 – Y0

  • apply_lut – Apply lut (Default value = False)

Returns:

Cross section along x-axis at y=y0

get_ysection(x0: float | int, apply_lut: bool = False) ndarray[source]

Return cross section along y-axis at x=x0

Parameters:
  • x0 – X0

  • apply_lut – Apply lut (Default value = False)

Returns:

Cross section along y-axis at x=x0

get_average_xsection(x0: float, y0: float, x1: float, y1: float, apply_lut: bool = False) ndarray[source]

Return average cross section along x-axis for the given rectangle

Parameters:
  • x0 – X0 of top left corner

  • y0 – Y0 of top left corner

  • x1 – X1 of bottom right corner

  • y1 – Y1 of bottom right corner

  • apply_lut – Apply lut (Default value = False)

Returns:

Average cross section along x-axis

get_average_ysection(x0: float, y0: float, x1: float, y1: float, apply_lut: bool = False) ndarray[source]

Return average cross section along y-axis

Parameters:
  • x0 – X0 of top left corner

  • y0 – Y0 of top left corner

  • x1 – X1 of bottom right corner

  • y1 – Y1 of bottom right corner

  • apply_lut – Apply lut (Default value = False)

Returns:

Average cross section along y-axis

class plotpy.items.RawImageItem(data: ndarray | None = None, param: Any | None = None)[source]

Construct a simple image item

get_default_param() RawImageParam[source]

Return instance of the default image param DataSet

Returns:

Default image param DataSet

Return type:

RawImageParam

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

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

load_data(lut_range: list[float, float] | None = None) None[source]

Load data from item filename attribute and eventually apply specified lut_range

Parameters:

lut_range – Lut range (Default value = None)

types() tuple[type[IItemType], ...][source]

Returns a group or category for this item. This should be a tuple of class objects inheriting from IItemType

Returns:

Tuple of class objects inheriting from IItemType

Return type:

tuple

update_item_parameters() None[source]

Update item parameters (dataset) from object properties

get_item_parameters(itemparams: ItemParameters) None[source]

Appends datasets to the list of DataSets describing the parameters used to customize apearance of this item

Parameters:

itemparams – Item parameters

set_item_parameters(itemparams: ItemParameters) None[source]

Change the appearance of this item according to the parameter set provided

Parameters:

itemparams – Item parameters

can_sethistogram() bool[source]

Returns True if this item can be associated with a levels histogram

Returns:

True if item can be associated with a levels histogram,

False otherwise

Return type:

bool

class plotpy.items.ImageItem(data: ndarray | None = None, param: ImageParam | None = None)[source]

Image item

Parameters:
  • data – 2D NumPy array

  • param – Image parameters

get_default_param() ImageParam[source]

Return instance of the default image param DataSet

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

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

get_xdata(aligned=True) tuple[float, float][source]

Get X data range

Parameters:

aligned – True if aligned (Default value = True)

Returns:

(xmin, xmax) tuple

get_ydata(aligned=True) tuple[float, float][source]

Get Y data range

Parameters:

aligned – True if aligned (Default value = True)

Returns:

(ymin, ymax) tuple

set_xdata(xmin: float | None = None, xmax: float | None = None) None[source]

Set X data range

Parameters:
  • xmin – Minimum X value

  • xmax – Maximum X value

set_ydata(ymin: float | None = None, ymax: float | None = None) None[source]

Set Y data range

Parameters:
  • ymin – Minimum Y value

  • ymax – Maximum Y value

update_bounds() None[source]

Update image bounds to fit image shape

get_pixel_coordinates(xplot: float, yplot: float) tuple[float, float][source]

Get pixel coordinates from plot coordinates

Parameters:
  • xplot – X plot coordinate

  • yplot – Y plot coordinate

Returns:

Pixel coordinates

get_plot_coordinates(xpixel: float, ypixel: float) tuple[float, float][source]

Get plot coordinates from pixel coordinates

Parameters:
  • xpixel – X pixel coordinate

  • ypixel – Y pixel coordinate

Returns:

Plot coordinates

get_x_values(i0: int, i1: int) ndarray[source]

Get X values from pixel indexes

Parameters:
  • i0 – First index

  • i1 – Second index

Returns:

X values corresponding to the given pixel indexes

get_y_values(j0: int, j1: int) ndarray[source]

Get Y values from pixel indexes

Parameters:
  • j0 – First index

  • j1 – Second index

Returns:

Y values corresponding to the given pixel indexes

get_closest_coordinates(x: float, y: float) tuple[float, float][source]

Get the closest coordinates to the given point

Parameters:
  • x – X coordinate

  • y – Y coordinate

Returns:

Closest coordinates

Return type:

tuple[float, float]

draw_image(painter: QPainter, canvasRect: QRectF, src_rect: tuple[float, float, float, float], dst_rect: tuple[float, float, float, float], xMap: qwt.scale_map.QwtScaleMap, yMap: qwt.scale_map.QwtScaleMap) None[source]

Draw image

Parameters:
  • painter – Painter

  • canvasRect – Canvas rectangle

  • src_rect – Source rectangle

  • dst_rect – Destination rectangle

  • xMap – X axis scale map

  • yMap – Y axis scale map

export_roi(src_rect: tuple[float, float, float, float], dst_rect: tuple[float, float, float, float], dst_image: ndarray, apply_lut: bool = False, apply_interpolation: bool = False, original_resolution: bool = False, force_interp_mode: str | None = None, force_interp_size: int | None = None) None[source]

Export a rectangular area of the image to another image

Parameters:
  • src_rect – Source rectangle

  • dst_rect – Destination rectangle

  • dst_image – Destination image

  • apply_lut – Apply lut (Default value = False)

  • apply_interpolation – Apply interpolation (Default value = False)

  • original_resolution – Original resolution (Default value = False)

  • force_interp_mode – Force interpolation mode (Default value = None)

  • force_interp_size – Force interpolation size (Default value = None)

move_local_point_to(handle: int, pos: QPointF, ctrl: bool = None) None[source]

Move a handle as returned by hit_test to the new position

Parameters:
  • handle – Handle

  • pos – Position

  • ctrl – True if <Ctrl> button is being pressed, False otherwise

move_local_shape(old_pos: QPointF, new_pos: QPointF) None[source]

Translate the shape such that old_pos becomes new_pos in canvas coordinates

Parameters:
  • old_pos – Old position

  • new_pos – New position

move_with_selection(delta_x: float, delta_y: float) None[source]

Translate the item together with other selected items

Parameters:
  • delta_x – Translation in plot coordinates along x-axis

  • delta_y – Translation in plot coordinates along y-axis

class plotpy.items.TrImageItem(data=None, param=None)[source]

Construct a transformable image item

get_default_param()[source]

Return instance of the default image param DataSet

set_crop(left, top, right, bottom)[source]
Parameters:
  • left

  • top

  • right

  • bottom

get_crop()[source]
Returns:

get_crop_coordinates()[source]

Return crop rectangle coordinates

set_data(data: ndarray, lut_range: list[float, float] | None = None) None[source]

Set image data

Parameters:
  • data – 2D NumPy array

  • lut_range – LUT range – tuple (levelmin, levelmax) (Default value = None)

get_filter(filterobj, filterparam)[source]

Provides a filter object over this image’s content

get_pixel_coordinates(xplot: float, yplot: float) tuple[float, float][source]

Get pixel coordinates from plot coordinates

Parameters:
  • xplot – X plot coordinate

  • yplot – Y plot coordinate

Returns:

Pixel coordinates

get_plot_coordinates(xpixel: float, ypixel: float) tuple[float, float][source]

Get plot coordinates from pixel coordinates

Parameters:
  • xpixel – X pixel coordinate

  • ypixel – Y pixel coordinate

Returns:

Plot coordinates

get_x_values(i0: int, i1: int) ndarray[source]

Get X values from pixel indexes

Parameters:
  • i0 – First index

  • i1 – Second index

Returns:

X values corresponding to the given pixel indexes

get_y_values(j0: int, j1: int) ndarray[source]

Get Y values from pixel indexes

Parameters:
  • j0 – First index

  • j1 – Second index

Returns:

Y values corresponding to the given pixel indexes

get_r_values(i0, i1, j0, j1, flag_circle=False)[source]

Get radial values from pixel indexes

Parameters:
  • i0 – First index

  • i1 – Second index

  • j0 – Third index

  • j1 – Fourth index

  • flag_circle – Flag circle (Default value = False)

Returns:

Radial values corresponding to the given pixel indexes

get_closest_coordinates(x: float, y: float) tuple[float, float][source]

Get the closest coordinates to the given point

Parameters:
  • x – X coordinate

  • y – Y coordinate

Returns:

Closest coordinates

Return type:

tuple[float, float]

update_border() None[source]

Update image border rectangle to fit image shape

draw_image(painter: QPainter, canvasRect: QRectF, src_rect: tuple[float, float, float, float], dst_rect: tuple[float, float, float, float], xMap: qwt.scale_map.QwtScaleMap, yMap: qwt.scale_map.QwtScaleMap) None[source]

Draw image

Parameters:
  • painter – Painter

  • canvasRect – Canvas rectangle

  • src_rect – Source rectangle

  • dst_rect – Destination rectangle

  • xMap – X axis scale map

  • yMap – Y axis scale map

export_roi(src_rect: tuple[float, float, float, float], dst_rect: tuple[float, float, float, float], dst_image: ndarray, apply_lut: bool = False, apply_interpolation: bool = False, original_resolution: bool = False, force_interp_mode: str | None = None, force_interp_size: int | None = None) None[source]

Export a rectangular area of the image to another image

Parameters:
  • src_rect – Source rectangle

  • dst_rect – Destination rectangle

  • dst_image – Destination image

  • apply_lut – Apply lut (Default value = False)

  • apply_interpolation – Apply interpolation (Default value = False)

  • original_resolution – Original resolution (Default value = False)

  • force_interp_mode – Force interpolation mode (Default value = None)

  • force_interp_size – Force interpolation size (Default value = None)

move_local_point_to(handle: int, pos: QPointF, ctrl: bool = None) None[source]

Move a handle as returned by hit_test to the new position

Parameters:
  • handle – Handle

  • pos – Position

  • ctrl – True if <Ctrl> button is being pressed, False otherwise

move_local_shape(old_pos: QPointF, new_pos: QPointF) None[source]

Translate the shape such that old_pos becomes new_pos in canvas coordinates

Parameters:
  • old_pos – Old position

  • new_pos – New position

rotate_local_shape(old_pos, new_pos)[source]

Contrairement à move_local_point_to, le déplacement se fait entre les deux positions et non pas depuis un handle jusqu’à un point

move_with_arrows(dx, dy)[source]

Translate the shape with arrows in canvas coordinates

rotate_with_arrows(dangle)[source]

Rotate the shape with arrows in canvas coordinates angle0 : old rotation angle angle1 : new rotation angle

move_with_selection(delta_x: float, delta_y: float) None[source]

Translate the item together with other selected items

Parameters:
  • delta_x – Translation in plot coordinates along x-axis

  • delta_y – Translation in plot coordinates along y-axis

resize_with_selection(zoom_dx, zoom_dy)[source]

Resize the shape together with other selected items zoom_dx, zoom_dy : zoom factor for dx and dy

rotate_with_selection(angle)[source]

Rotate the shape together with other selected items angle0 : old rotation angle angle1 : new rotation angle

set_transform(x0, y0, angle, dx=1.0, dy=1.0, hflip=False, vflip=False)[source]

Set the transformation

Parameters:
  • x0 – X translation

  • y0 – Y translation

  • angle – rotation angle in radians

  • dx – X-scaling factor

  • dy – Y-scaling factor

  • hflip – True if image if flip horizontally

  • vflip – True if image is flip vertically

get_transform()[source]

Return the transformation parameters

Returns:

tuple (x0, y0, angle, dx, dy, hflip, yflip)

debug_transform(pt)[source]

Print debug data on how the given point is moved.

Parameters:

pt – array (x, y, z=1)

class plotpy.items.XYImageItem(x: ndarray | None = None, y: ndarray | None = None, data: ndarray | None = None, param: XYImageParam | None = None)[source]

XY image item (non-linear axes)

Parameters:
  • x – 1D NumPy array, must be increasing

  • y – 1D NumPy array, must be increasing

  • data – 2D NumPy array

  • param – image parameters

get_default_param() XYImageParam[source]

Return instance of the default image param DataSet

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

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

set_xy(x: ndarray | list[float], y: ndarray | list[float]) None[source]

Set X and Y data

Parameters:
  • x – 1D NumPy array, must be increasing

  • y – 1D NumPy array, must be increasing

Raises:
get_filter(filterobj, filterparam)[source]

Provides a filter object over this image’s content

draw_image(painter: QPainter, canvasRect: QRectF, src_rect: tuple[float, float, float, float], dst_rect: tuple[float, float, float, float], xMap: qwt.scale_map.QwtScaleMap, yMap: qwt.scale_map.QwtScaleMap) None[source]

Draw image

Parameters:
  • painter – Painter

  • canvasRect – Canvas rectangle

  • src_rect – Source rectangle

  • dst_rect – Destination rectangle

  • xMap – X axis scale map

  • yMap – Y axis scale map

get_pixel_coordinates(xplot: float, yplot: float) tuple[float, float][source]

Get pixel coordinates from plot coordinates

Parameters:
  • xplot – X plot coordinate

  • yplot – Y plot coordinate

Returns:

Pixel coordinates

get_plot_coordinates(xpixel: float, ypixel: float) tuple[float, float][source]

Get plot coordinates from pixel coordinates

Parameters:
  • xpixel – X pixel coordinate

  • ypixel – Y pixel coordinate

Returns:

Plot coordinates

get_x_values(i0: int, i1: int) ndarray[source]

Get X values from pixel indexes

Parameters:
  • i0 – First index

  • i1 – Second index

Returns:

X values corresponding to the given pixel indexes

get_y_values(j0: int, j1: int) ndarray[source]

Get Y values from pixel indexes

Parameters:
  • j0 – First index

  • j1 – Second index

Returns:

Y values corresponding to the given pixel indexes

get_closest_coordinates(x: float, y: float) tuple[float, float][source]

Get the closest coordinates to the given point

Parameters:
  • x – X coordinate

  • y – Y coordinate

Returns:

Closest coordinates

Return type:

tuple[float, float]

types() tuple[type[IItemType], ...][source]

Returns a group or category for this item. This should be a tuple of class objects inheriting from IItemType

Returns:

Tuple of class objects inheriting from IItemType

Return type:

tuple

can_sethistogram() bool[source]

Returns True if this item can be associated with a levels histogram

Returns:

True if item can be associated with a levels histogram,

False otherwise

Return type:

bool

class plotpy.items.RGBImageItem(data: ndarray | None = None, param: RGBImageParam | None = None)[source]

RGB image item

Parameters:
  • data – 3D NumPy array (shape: NxMx[34] – 3: RGB, 4: RGBA)

  • param – image parameters

get_default_param() RGBImageParam[source]

Return instance of the default image param DataSet

recompute_alpha_channel() None[source]

Recompute alpha channel

set_lut_range(lut_range: tuple[float, float]) None[source]

Set the current active lut range

Warning

This method is not implemented for this item type.

set_background_color(qcolor: QColor | str) None[source]

Set background color

Parameters:

qcolor – Background color

Warning

This method is not implemented for this item type.

set_color_map(name_or_table: str | EditableColormap, invert: bool | None = None) None[source]

Set colormap

Parameters:
  • name_or_table – Colormap name or colormap

  • invert – True to invert colormap, False otherwise (Default value = None, i.e. do not change the default behavior)

load_data() None[source]

Load data from item filename attribute

set_data(data: ndarray) None[source]

Set image data

Parameters:

data – 2D NumPy array

types() tuple[type[IItemType], ...][source]

Returns a group or category for this item. This should be a tuple of class objects inheriting from IItemType

Returns:

Tuple of class objects inheriting from IItemType

Return type:

tuple

can_sethistogram() bool[source]

Returns True if this item can be associated with a levels histogram

Returns:

True if item can be associated with a levels histogram,

False otherwise

Return type:

bool

class plotpy.items.MaskedArea(geometry: str | None = None, x0: float | None = None, y0: float | None = None, x1: float | None = None, y1: float | None = None, inside: bool | None = None)[source]

Defines masked areas for a masked image item

Parameters:
  • geometry – Geometry of the area (‘rectangular’ or anything else for circular)

  • x0 – X coordinate of first point

  • y0 – Y coordinate of first point

  • x1 – X coordinate of second point

  • y1 – Y coordinate of second point

  • inside – True if the area is inside the geometry, False if it is outside

serialize(writer: HDF5Writer | INIWriter | JSONWriter) None[source]

Serialize object to HDF5 writer

Parameters:

writer – HDF5, INI or JSON writer

deserialize(reader: HDF5Reader | INIReader | JSONReader) None[source]

Deserialize object from HDF5 reader

Parameters:

reader – HDF5, INI or JSON reader

class plotpy.items.MaskedImageItem(data: ndarray | None = None, mask: ndarray | None = None, param: MaskedImageParam | None = None)[source]

Masked image item

Parameters:
  • data – 2D NumPy array

  • mask – 2D NumPy array

  • param – image parameters

get_default_param() MaskedImageParam[source]

Return instance of the default MaskedImageParam DataSet

serialize(writer: HDF5Writer | INIWriter | JSONWriter) None[source]

Serialize object to HDF5 writer

Parameters:

writer – HDF5, INI or JSON writer

deserialize(reader: HDF5Reader | INIReader | JSONReader) None[source]

Deserialize object from HDF5 reader

Parameters:

reader – HDF5, INI or JSON reader

draw_image(painter: QPainter, canvasRect: QRectF, src_rect: tuple[float, float, float, float], dst_rect: tuple[float, float, float, float], xMap: qwt.scale_map.QwtScaleMap, yMap: qwt.scale_map.QwtScaleMap) None[source]

Draw image

Parameters:
  • painter – Painter

  • canvasRect – Canvas rectangle

  • src_rect – Source rectangle

  • dst_rect – Destination rectangle

  • xMap – X axis scale map

  • yMap – Y axis scale map

set_data(data: ndarray, lut_range: list[float, float] | None = None) None[source]

Set image data

Parameters:
  • data – 2D NumPy array

  • lut_range – LUT range – tuple (levelmin, levelmax) (Default value = None)

class plotpy.items.MaskedXYImageItem(x: ndarray | None = None, y: ndarray | None = None, data: ndarray | None = None, mask: ndarray | None = None, param: MaskedXYImageParam | None = None)[source]

XY masked image item

Parameters:
  • x – 1D NumPy array, must be increasing

  • y – 1D NumPy array, must be increasing

  • data – 2D NumPy array

  • mask – 2D NumPy array

  • param – image parameters

get_default_param() MaskedXYImageParam[source]

Return instance of the default MaskedXYImageParam DataSet

serialize(writer: HDF5Writer | INIWriter | JSONWriter) None[source]

Serialize object to HDF5 writer

Parameters:

writer – HDF5, INI or JSON writer

deserialize(reader: HDF5Reader | INIReader | JSONReader) None[source]

Deserialize object from HDF5 reader

Parameters:

reader – HDF5, INI or JSON reader

draw_image(painter: QPainter, canvasRect: QRectF, src_rect: tuple[float, float, float, float], dst_rect: tuple[float, float, float, float], xMap: qwt.scale_map.QwtScaleMap, yMap: qwt.scale_map.QwtScaleMap) None[source]

Draw image

Parameters:
  • painter – Painter

  • canvasRect – Canvas rectangle

  • src_rect – Source rectangle

  • dst_rect – Destination rectangle

  • xMap – X axis scale map

  • yMap – Y axis scale map

set_data(data: ndarray, lut_range: list[float, float] | None = None) None[source]

Set image data

Parameters:
  • data – 2D NumPy array

  • lut_range – LUT range – tuple (levelmin, levelmax) (Default value = None)

class plotpy.items.ImageFilterItem(image: RawImageItem | None, filter: Callable, param: ImageFilterParam)[source]

Construct a rectangular area image filter item

set_image(image: RawImageItem | None) None[source]

Set the image item on which the filter will be applied

set_filter(filter: Callable) None[source]

Set the filter function

  • filter: function (x, y, data) –> data

boundingRect() QRectF[source]

Return the bounding rectangle of the shape

Returns:

Bounding rectangle of the shape

update_item_parameters() None[source]

Update item parameters (dataset) from object properties

get_item_parameters(itemparams: ItemParameters) None[source]

Appends datasets to the list of DataSets describing the parameters used to customize apearance of this item

Parameters:

itemparams – Item parameters

set_item_parameters(itemparams: ItemParameters) None[source]

Change the appearance of this item according to the parameter set provided

Parameters:

itemparams – Item parameters

move_local_point_to(handle: int, pos: QPointF, ctrl: bool = None) None[source]

Move a handle as returned by hit_test to the new position

Parameters:
  • handle – Handle

  • pos – Position

  • ctrl – True if <Ctrl> button is being pressed, False otherwise

move_local_shape(old_pos: QPointF, new_pos: QPointF) None[source]

Translate the shape such that old_pos becomes new_pos in canvas coordinates

Parameters:
  • old_pos – Old position

  • new_pos – New position

move_with_selection(delta_x: float, delta_y: float) None[source]

Translate the item together with other selected items

Parameters:
  • delta_x – Translation in plot coordinates along x-axis

  • delta_y – Translation in plot coordinates along y-axis

set_color_map(name_or_table: str | EditableColormap, invert: bool | None = None) None[source]

Set colormap

Parameters:
  • name_or_table – Colormap name or colormap

  • invert – True to invert colormap, False otherwise (Default value = None, i.e. do not change the default behavior)

get_color_map() qwt.color_map.QwtLinearColorMap[source]

Get colormap

get_lut_range() tuple[float, float][source]

Get the current active lut range

Returns:

Lut range, tuple(min, max)

Return type:

tuple[float, float]

set_lut_range(lut_range: tuple[float, float]) None[source]

Set the current active lut range

Parameters:

lut_range – Lut range, tuple(min, max)

Example

>>> item.set_lut_range((0.0, 1.0))
types() tuple[type[IItemType], ...][source]

Returns a group or category for this item. This should be a tuple of class objects inheriting from IItemType

Returns:

Tuple of class objects inheriting from IItemType

Return type:

tuple

can_sethistogram() bool[source]

Returns True if this item can be associated with a levels histogram

Returns:

True if item can be associated with a levels histogram,

False otherwise

Return type:

bool

class plotpy.items.XYImageFilterItem(image: XYImageItem, filter: Callable, param: ImageFilterParam)[source]

Construct a rectangular area image filter item

set_image(image)[source]

Set the image item on which the filter will be applied

draw_image(painter: QPainter, canvasRect: QRectF, src_rect: tuple[float, float, float, float], dst_rect: tuple[float, float, float, float], xMap: qwt.scale_map.QwtScaleMap, yMap: qwt.scale_map.QwtScaleMap) None[source]

Draw image

Parameters:
  • painter – Painter

  • canvasRect – Canvas rectangle

  • src_rect – Source rectangle

  • dst_rect – Destination rectangle

  • xMap – X axis scale map

  • yMap – Y axis scale map

class plotpy.items.QuadGridItem(X: ndarray, Y: ndarray, Z: ndarray, param: QuadGridParam | None = None)[source]

Quad grid item

Parameters:
  • X – X coordinates

  • Y – Y coordinates

  • Z – Z coordinates

  • param – Image parameters

X, Y, Z: A structured grid of quadrilaterals, each quad is defined by (X[i], Y[i]), (X[i], Y[i+1]), (X[i+1], Y[i+1]), (X[i+1], Y[i])

get_default_param() QuadGridParam[source]

Return instance of the default image param DataSet

types() tuple[type[IItemType], ...][source]

Returns a group or category for this item. This should be a tuple of class objects inheriting from IItemType

Returns:

Tuple of class objects inheriting from IItemType

Return type:

tuple

update_bounds() None[source]

Update image bounds to fit image shape

set_data(data: ndarray, X: ndarray | None = None, Y: ndarray | None = None, lut_range: list[float, float] | None = None) None[source]

Set image data

Parameters:
  • data – 2D NumPy array

  • X – X coordinates (Default value = None)

  • Y – Y coordinates (Default value = None)

  • lut_range – LUT range – tuple (levelmin, levelmax) (Default value = None)

draw_image(painter: QPainter, canvasRect: QRectF, src_rect: tuple[float, float, float, float], dst_rect: tuple[float, float, float, float], xMap: qwt.scale_map.QwtScaleMap, yMap: qwt.scale_map.QwtScaleMap) None[source]

Draw image

Parameters:
  • painter – Painter

  • canvasRect – Canvas rectangle

  • src_rect – Source rectangle

  • dst_rect – Destination rectangle

  • xMap – X axis scale map

  • yMap – Y axis scale map

notify_new_offscreen() None[source]

Notify that the offscreen image has changed

plotpy.items.assemble_imageitems(items: list[BaseImageItem], src_qrect: QRectF, destw: int, desth: int, align: int | None = None, add_images: bool = False, apply_lut: bool = False, apply_interpolation: bool = False, original_resolution: bool = False, force_interp_mode: str | None = None, force_interp_size: int | None = None) ndarray[source]

Assemble together image items and return resulting pixel data

Parameters:
  • items – List of image items

  • src_qrect – Source rectangle

  • destw – Destination width

  • desth – Destination height

  • align – Alignment (Default value = None)

  • add_images – Add images (Default value = False)

  • apply_lut – Apply LUT (Default value = False)

  • apply_interpolation – Apply interpolation (Default value = False)

  • original_resolution – Original resolution (Default value = False)

  • force_interp_mode – Force interpolation mode (Default value = None)

  • force_interp_size – Force interpolation size (Default value = None)

Returns:

Pixel data

Warning

Does not support XYImageItem objects

plotpy.items.get_plot_qrect(plot: qwt.plot.QwtPlot, p0: QPointF, p1: QPointF) QRectF[source]

Get plot rectangle, in plot coordinates, from two canvas points

Parameters:
  • plot – Plot

  • p0 – First point

  • p1 – Second point

Returns:

Plot rectangle

plotpy.items.get_image_from_plot(plot: BasePlot, p0: QPointF, p1: QPointF, destw: int | None = None, desth: int | None = None, add_images: bool = False, apply_lut: bool = False, apply_interpolation: bool = False, original_resolution: bool = False, force_interp_mode: str | None = None, force_interp_size: int | None = None) numpy.ndarray[source]

Get image pixel data from plot area

Parameters:
  • plot – Plot

  • p0 – First point (top-left)

  • p1 – Second point (bottom-right)

  • destw – Destination width (Default value = None)

  • desth – Destination height (Default value = None)

  • add_images – Add superimposed images (instead of replace by the foreground)

  • apply_lut – Apply LUT (Default value = False)

  • apply_interpolation – Apply interpolation (Default value = False)

  • original_resolution – Original resolution (Default value = False)

  • force_interp_mode – Force interpolation mode (Default value = None)

  • force_interp_size – Force interpolation size (Default value = None)

Returns:

Image pixel data

Warning

Support only the image items implementing the IExportROIImageItemType interface, i.e. this does not support XYImageItem objects

Contours

class plotpy.items.ContourItem(points=None, shapeparam=None)[source]

Contour shape

class plotpy.items.contour.ContourLine(title: str | None = None, comment: str | None = None, icon: str = '', readonly: bool = False)[source]

A contour line

plotpy.items.contour.compute_contours(Z: ndarray, levels: float | ndarray, X: ndarray | None = None, Y: ndarray | None = None) list[ContourLine][source]

Create contour curves

Parameters:
  • Z – The height values over which the contour is drawn.

  • levels – Determines the number and positions of the contour lines/regions. If a float, draw contour lines at this specified levels If array-like, draw contour lines at the specified levels. The values must be in increasing order.

  • X – The coordinates of the values in Z. X must be 2-D with the same shape as Z (e.g. created via numpy.meshgrid), or it must both be 1-D such that len(X) == M is the number of columns in Z. If none, they are assumed to be integer indices, i.e. X = range(M).

  • Y – The coordinates of the values in Z. Y must be 2-D with the same shape as Z (e.g. created via numpy.meshgrid), or it must both be 1-D such that len(Y) == N is the number of rows in Z. If none, they are assumed to be integer indices, i.e. Y = range(N).

Returns:

A list of ContourLine instances.

plotpy.items.create_contour_items(Z: ndarray, levels: float | ndarray, X: ndarray | None = None, Y: ndarray | None = None) list[ContourItem][source]

Create contour items

Parameters:
  • Z – The height values over which the contour is drawn.

  • levels – Determines the number and positions of the contour lines/regions. If a float, draw contour lines at this specified levels If array-like, draw contour lines at the specified levels. The values must be in increasing order.

  • X – The coordinates of the values in Z. X must be 2-D with the same shape as Z (e.g. created via numpy.meshgrid), or it must both be 1-D such that len(X) == M is the number of columns in Z. If none, they are assumed to be integer indices, i.e. X = range(M).

  • Y – The coordinates of the values in Z. Y must be 2-D with the same shape as Z (e.g. created via numpy.meshgrid), or it must both be 1-D such that len(Y) == N is the number of rows in Z. If none, they are assumed to be integer indices, i.e. Y = range(N).

Returns:

A list of ContourItem instances.

Histograms

class plotpy.items.HistogramItem(curveparam: CurveParam | None = None, histparam: HistogramParam | None = None, keep_weakref: bool = False)[source]

Histogram plot item

Parameters:
  • curveparam – Curve parameters

  • histparam – Histogram parameters

set_hist_source(src: BaseImageItem) None[source]

Set histogram source

Parameters:

src – Object with method get_histogram, e.g. objects derived from ImageItem

get_hist_source() BaseImageItem | None[source]

Return histogram source

Returns:

Object with method get_histogram, e.g. objects derived from

ImageItem

Return type:

object

set_hist_data(data: ndarray) None[source]

Set histogram data

Parameters:

data – numpy array

set_logscale(state: bool) None[source]

Sets whether we use a logarithm or linear scale for the histogram counts

Parameters:

state – True for logarithmic scale

get_logscale() bool | None[source]

Returns the status of the scale

Returns:

True for logarithmic scale

Return type:

bool

set_bins(n_bins: int) None[source]

Sets the number of bins

Parameters:

n_bins – number of bins

get_bins() int | None[source]

Returns the number of bins

Returns:

number of bins

Return type:

int

set_bin_range(bin_range: tuple[float, float] | None) None[source]

Sets the range of the bins

Parameters:

bin_range – (min, max) or None for automatic range

get_bin_range() tuple[float, float] | None[source]

Returns the range of the bins

Returns:

(min, max)

Return type:

tuple

compute_histogram() tuple[ndarray, ndarray][source]

Compute histogram data

Returns:

(hist, bins)

Return type:

tuple

update_histogram() None[source]

Update histogram data

update_params()[source]

Update histogram parameters

get_item_parameters(itemparams: ItemParameters) None[source]

Appends datasets to the list of DataSets describing the parameters used to customize apearance of this item

Parameters:

itemparams – Item parameters

set_item_parameters(itemparams)[source]
Parameters:

itemparams

class plotpy.items.Histogram2DItem(X: ndarray, Y: ndarray, param: Histogram2DParam | None = None, Z=None)[source]

2D histogram item

Parameters:
  • X – X coordinates (1-D array)

  • Y – Y coordinates (1-D array)

  • param – Histogram parameters

get_default_param() Histogram2DParam[source]

Return instance of the default image param DataSet

set_bins(NX: int, NY: int) None[source]

Set histogram bins

Parameters:
  • NX – Number of bins along X

  • NY – Number of bins along Y

set_data(X: ndarray, Y: ndarray, Z: ndarray | None = None) None[source]

Set histogram data

Parameters:
  • X – X coordinates

  • Y – Y coordinates

  • Z – Z coordinates (Default value = None)

draw_image(painter: QPainter, canvasRect: QRectF, src_rect: tuple[float, float, float, float], dst_rect: tuple[float, float, float, float], xMap: qwt.scale_map.QwtScaleMap, yMap: qwt.scale_map.QwtScaleMap) None[source]

Draw image

Parameters:
  • painter – Painter

  • canvasRect – Canvas rectangle

  • src_rect – Source rectangle

  • dst_rect – Destination rectangle

  • xMap – X axis scale map

  • yMap – Y axis scale map

types() tuple[type[IItemType], ...][source]

Returns a group or category for this item. This should be a tuple of class objects inheriting from IItemType

Returns:

Tuple of class objects inheriting from IItemType

Return type:

tuple

update_item_parameters() None[source]

Update item parameters (dataset) from object properties

get_item_parameters(itemparams: ItemParameters) None[source]

Appends datasets to the list of DataSets describing the parameters used to customize apearance of this item

Parameters:

itemparams – Item parameters

set_item_parameters(itemparams: ItemParameters) None[source]

Change the appearance of this item according to the parameter set provided

Parameters:

itemparams – Item parameters

can_sethistogram() bool[source]

Returns True if this item can be associated with a levels histogram

Returns:

True if item can be associated with a levels histogram,

False otherwise

Return type:

bool

get_histogram(nbins: int, drange: tuple[float, float] | None = None) tuple[ndarray, ndarray][source]

Return a tuple (hist, bins) where hist is a list of histogram values

Parameters:
  • nbins – number of bins

  • drange – lower and upper range of the bins. If not provided, range is simply (data.min(), data.max()). Values outside the range are ignored.

Returns:

Tuple (hist, bins)

Grid

class plotpy.items.GridItem(gridparam: GridParam | None = None)[source]

Grid plot item

Parameters:

gridparam – Grid parameters

types() tuple[type[IItemType], ...][source]

Returns a group or category for this item. This should be a tuple of class objects inheriting from IItemType

Returns:

Tuple of class objects inheriting from IItemType

Return type:

tuple

attach(plot: QwtPlot) None[source]

Reimplemented to update plot canvas background

set_readonly(state: bool) None[source]

Set object readonly state

Parameters:

state – True if object is readonly, False otherwise

is_readonly() bool[source]

Return object readonly state

Returns:

True if object is readonly, False otherwise

Return type:

bool

set_private(state: bool) None[source]

Set object as private

Parameters:

state – True if object is private, False otherwise

is_private() bool[source]

Return True if object is private

Returns:

True if object is private, False otherwise

Return type:

bool

set_selectable(state: bool) None[source]

Set item selectable state

Parameters:

state – True if item is selectable, False otherwise

set_resizable(state: bool) None[source]

Set item resizable state (or any action triggered when moving an handle, e.g. rotation)

Parameters:

state – True if item is resizable, False otherwise

set_movable(state: bool) None[source]

Set item movable state

Parameters:

state – True if item is movable, False otherwise

set_rotatable(state: bool) None[source]

Set item rotatable state

Parameters:

state – True if item is rotatable, False otherwise

can_select() bool[source]

Returns True if this item can be selected

Returns:

True if item can be selected, False otherwise

Return type:

bool

can_resize() bool[source]

Returns True if this item can be resized

Returns:

True if item can be resized, False otherwise

Return type:

bool

can_rotate() bool[source]

Returns True if this item can be rotated

Returns:

True if item can be rotated, False otherwise

Return type:

bool

can_move() bool[source]

Returns True if this item can be moved

Returns:

True if item can be moved, False otherwise

Return type:

bool

select() None[source]

Select the object and eventually change its appearance to highlight the fact that it’s selected

unselect() None[source]

Unselect the object and eventually restore its original appearance to highlight the fact that it’s not selected anymore

hit_test(pos: QPointF) tuple[float, float, bool, None][source]

Return a tuple (distance, attach point, inside, other_object)

Parameters:

pos – Position

Returns:

Tuple with four elements: (distance, attach point, inside,

other_object).

Return type:

tuple

Description of the returned values:

  • distance: distance in pixels (canvas coordinates) to the closest

    attach point

  • attach point: handle of the attach point

  • inside: True if the mouse button has been clicked inside the object

  • other_object: if not None, reference of the object which will be

    considered as hit instead of self

move_local_point_to(handle: int, pos: QPointF, ctrl: bool = None) None[source]

Move a handle as returned by hit_test to the new position

Parameters:
  • handle – Handle

  • pos – Position

  • ctrl – True if <Ctrl> button is being pressed, False otherwise

move_local_shape(old_pos: QPointF, new_pos: QPointF) None[source]

Translate the shape such that old_pos becomes new_pos in canvas coordinates

Parameters:
  • old_pos – Old position

  • new_pos – New position

move_with_selection(delta_x: float, delta_y: float) None[source]

Translate the item together with other selected items

Parameters:
  • delta_x – Translation in plot coordinates along x-axis

  • delta_y – Translation in plot coordinates along y-axis

update_params()[source]

Update object parameters (dataset) from object properties

update_item_parameters() None[source]

Update item parameters (dataset) from object properties

get_item_parameters(itemparams: ItemParameters) None[source]

Appends datasets to the list of DataSets describing the parameters used to customize apearance of this item

Parameters:

itemparams – Item parameters

set_item_parameters(itemparams: ItemParameters) None[source]

Change the appearance of this item according to the parameter set provided

Parameters:

itemparams – Item parameters

Shapes

class plotpy.items.AbstractShape[source]

Abstract shape class

set_selectable(state: bool) None[source]

Set item selectable state

Parameters:

state – True if item is selectable, False otherwise

set_resizable(state: bool) None[source]

Set item resizable state (or any action triggered when moving an handle, e.g. rotation)

Parameters:

state – True if item is resizable, False otherwise

set_movable(state: bool) None[source]

Set item movable state

Parameters:

state – True if item is movable, False otherwise

set_rotatable(state: bool) None[source]

Set item rotatable state

Parameters:

state – True if item is rotatable, False otherwise

can_select() bool[source]

Returns True if this item can be selected

Returns:

True if item can be selected, False otherwise

Return type:

bool

can_resize() bool[source]

Returns True if this item can be resized

Returns:

True if item can be resized, False otherwise

Return type:

bool

can_rotate() bool[source]

Returns True if this item can be rotated

Returns:

True if item can be rotated, False otherwise

Return type:

bool

can_move() bool[source]

Returns True if this item can be moved

Returns:

True if item can be moved, False otherwise

Return type:

bool

types() tuple[type[IItemType], ...][source]

Returns a group or category for this item. This should be a tuple of class objects inheriting from IItemType

Returns:

Tuple of class objects inheriting from IItemType

Return type:

tuple

set_readonly(state: bool) None[source]

Set object readonly state

Parameters:

state – True if object is readonly, False otherwise

is_readonly() bool[source]

Return object readonly state

Returns:

True if object is readonly, False otherwise

Return type:

bool

set_private(state: bool) None[source]

Set object as private

Parameters:

state – True if object is private, False otherwise

is_private() bool[source]

Return True if object is private

Returns:

True if object is private, False otherwise

Return type:

bool

select() None[source]

Select the object and eventually change its appearance to highlight the fact that it’s selected

unselect() None[source]

Unselect the object and eventually restore its original appearance to highlight the fact that it’s not selected anymore

hit_test(pos: QPointF) tuple[float, float, bool, None][source]

Return a tuple (distance, attach point, inside, other_object)

Parameters:

pos – Position

Returns:

Tuple with four elements: (distance, attach point, inside,

other_object).

Return type:

tuple

Description of the returned values:

  • distance: distance in pixels (canvas coordinates) to the closest

    attach point

  • attach point: handle of the attach point

  • inside: True if the mouse button has been clicked inside the object

  • other_object: if not None, reference of the object which will be

    considered as hit instead of self

update_item_parameters() None[source]

Update item parameters (dataset) from object properties

get_item_parameters(itemparams: ItemParameters) None[source]

Appends datasets to the list of DataSets describing the parameters used to customize apearance of this item

Parameters:

itemparams – Item parameters

set_item_parameters(itemparams)[source]

Change the appearance of this item according to the parameter set provided

params is a list of Datasets of the same types as those returned by get_item_parameters

move_local_point_to(handle: int, pos: QPointF, ctrl: bool = False) None[source]

Move a handle as returned by hit_test to the new position

Parameters:
  • handle – Handle

  • pos – Position

  • ctrl – True if <Ctrl> button is being pressed, False otherwise

move_local_shape(old_pos: QPointF, new_pos: QPointF) None[source]

Translate the shape such that old_pos becomes new_pos in canvas coordinates

Parameters:
  • old_pos – Old position

  • new_pos – New position

move_with_selection(delta_x: float, delta_y: float) None[source]

Translate the item together with other selected items

Parameters:
  • delta_x – Translation in plot coordinates along x-axis

  • delta_y – Translation in plot coordinates along y-axis

move_point_to(handle: int, pos: tuple[float, float], ctrl: bool = False) None[source]

Move a handle as returned by hit_test to the new position

Parameters:
  • handle – Handle

  • pos – Position

  • ctrl – True if <Ctrl> button is being pressed, False otherwise

move_shape(old_pos: QPointF, new_pos: QPointF) None[source]

Translate the shape such that old_pos becomes new_pos in axis coordinates

Parameters:
  • old_pos – Old position

  • new_pos – New position

invalidate_plot() None[source]

Invalidate the plot to force a redraw

is_empty() bool[source]

Return True if the item is empty

Returns:

True if the item is empty, False otherwise

class plotpy.items.PolygonShape(points: list[tuple[float, float]] | None = None, closed: bool | None = None, shapeparam: ShapeParam | None = None)[source]

Polygon shape class

Parameters:
  • points – List of point coordinates

  • closed – True if the polygon is closed, False otherwise

  • shapeparam – Shape parameters

types() tuple[type[IItemType], ...][source]

Returns a group or category for this item. This should be a tuple of class objects inheriting from IItemType

Returns:

Tuple of class objects inheriting from IItemType

Return type:

tuple

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

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

set_style(section: str, option: str) None[source]

Set style for this item

Parameters:
  • section – Section

  • option – Option

set_points(points: list[tuple[float, float]]) None[source]

Set polygon points

Parameters:

points – List of point coordinates

get_points() ndarray[source]

Return polygon points

Returns:

Polygon points (numpy array of shape (N, 2))

boundingRect() QRectF[source]

Return the bounding rectangle of the data

Returns:

Bounding rectangle of the data

is_empty() bool[source]

Return True if the item is empty

Returns:

True if the item is empty, False otherwise

get_bounding_rect_coords() tuple[float, float, float, float][source]

Return bounding rectangle coordinates (in plot coordinates)

Returns:

Bounding rectangle coordinates (in plot coordinates)

transform_points(xMap: qwt.scale_map.QwtScaleMap, yMap: qwt.scale_map.QwtScaleMap) QPolygonF[source]

Transform points to canvas coordinates

Parameters:
  • xMap – X axis scale map

  • yMap – Y axis scale map

Returns:

Transformed points

get_reference_point() tuple[float, float] | None[source]

Return a reference point for the item

Returns:

Reference point for the item

get_pen_brush(xMap: qwt.scale_map.QwtScaleMap, yMap: qwt.scale_map.QwtScaleMap) tuple[QPen, QBrush, qwt.symbol.QwtSymbol][source]

Get pen, brush and symbol for the item

Parameters:
  • xMap – X axis scale map

  • yMap – Y axis scale map

Returns:

Tuple with pen, brush and symbol for the item

draw(painter: QPainter, xMap: qwt.scale_map.QwtScaleMap, yMap: qwt.scale_map.QwtScaleMap, canvasRect: QRectF) None[source]

Draw the item

Parameters:
  • painter – Painter

  • xMap – X axis scale map

  • yMap – Y axis scale map

  • canvasRect – Canvas rectangle

poly_hit_test(plot: BasePlot, ax: int, ay: int, pos: QPointF) tuple[source]

Return a tuple (distance, attach point, inside, other_object)

Parameters:
  • plot – Plot

  • ax – X axis index

  • ay – Y axis index

  • pos – Position

Returns:

Tuple with four elements (distance, attach point, inside, other_object).

hit_test(pos: QPointF) tuple[float, float, bool, None][source]

Return a tuple (distance, attach point, inside, other_object)

Parameters:

pos – Position

Returns:

Tuple with four elements: (distance, attach point, inside,

other_object).

Return type:

tuple

Description of the returned values:

  • distance: distance in pixels (canvas coordinates) to the closest

    attach point

  • attach point: handle of the attach point

  • inside: True if the mouse button has been clicked inside the object

  • other_object: if not None, reference of the object which will be

    considered as hit instead of self

add_local_point(pos: tuple[float, float]) int[source]

Add a point in canvas coordinates (local coordinates)

Parameters:

pos – Position

Returns:

Handle of the added point

add_point(pt: tuple[float, float]) int[source]

Add a point in axis coordinates

Parameters:

pt – Position

Returns:

Handle of the added point

del_point(handle: int) int[source]

Delete a point

Parameters:

handle – Handle

Returns:

Handle of the deleted point

move_point_to(handle: int, pos: tuple[float, float], ctrl: bool = False) None[source]

Move a handle as returned by hit_test to the new position

Parameters:
  • handle – Handle

  • pos – Position

  • ctrl – True if <Ctrl> button is being pressed, False otherwise

move_shape(old_pos: QPointF, new_pos: QPointF) None[source]

Translate the shape such that old_pos becomes new_pos in axis coordinates

Parameters:
  • old_pos – Old position

  • new_pos – New position

update_item_parameters() None[source]

Update item parameters (dataset) from object properties

get_item_parameters(itemparams: ItemParameters) None[source]

Appends datasets to the list of DataSets describing the parameters used to customize apearance of this item

Parameters:

itemparams – Item parameters

set_item_parameters(itemparams: ItemParameters) None[source]

Change the appearance of this item according to the parameter set provided

Parameters:

itemparams – Item parameters

class plotpy.items.RectangleShape(x1: float = 0.0, y1: float = 0.0, x2: float = 0.0, y2: float = 0.0, shapeparam: ShapeParam | None = None)[source]

Rectangle shape

Parameters:
  • x1 – X coordinate of the top-left corner

  • y1 – Y coordinate of the top-left corner

  • x2 – X coordinate of the bottom-right corner

  • y2 – Y coordinate of the bottom-right corner

  • shapeparam – Shape parameters

set_rect(x1: float, y1: float, x2: float, y2: float) None[source]

Set the coordinates of the rectangle

Parameters:
  • x1 – X coordinate of the top-left corner

  • y1 – Y coordinate of the top-left corner

  • x2 – X coordinate of the bottom-right corner

  • y2 – Y coordinate of the bottom-right corner

get_rect() tuple[float, float, float, float][source]

Return the coordinates of the rectangle

Returns:

Coordinates of the rectangle

get_center() tuple[float, float][source]

Return center coordinates

Returns:

Center coordinates

move_point_to(handle: int, pos: tuple[float, float], ctrl: bool = False) None[source]

Move a handle as returned by hit_test to the new position

Parameters:
  • handle – Handle

  • pos – Position

  • ctrl – True if <Ctrl> button is being pressed, False otherwise

class plotpy.items.ObliqueRectangleShape(x0: float = 0.0, y0: float = 0.0, x1: float = 0.0, y1: float = 0.0, x2: float = 0.0, y2: float = 0.0, x3: float = 0.0, y3: float = 0.0, shapeparam: ShapeParam | None = None)[source]

Oblique rectangle shape

Parameters:
  • x0 – X coordinate of the top-left corner

  • y0 – Y coordinate of the top-left corner

  • x1 – X coordinate of the top-right corner

  • y1 – Y coordinate of the top-right corner

  • x2 – X coordinate of the bottom-right corner

  • y2 – Y coordinate of the bottom-right corner

  • x3 – X coordinate of the bottom-left corner

  • y3 – Y coordinate of the bottom-left corner

  • shapeparam – Shape parameters

set_rect(x0: float, y0: float, x1: float, y1: float, x2: float, y2: float, x3: float, y3: float) None[source]

Set the coordinates of the rectangle

Parameters:
  • x0 – X coordinate of the top-left corner

  • y0 – Y coordinate of the top-left corner

  • x1 – X coordinate of the top-right corner

  • y1 – Y coordinate of the top-right corner

  • x2 – X coordinate of the bottom-right corner

  • y2 – Y coordinate of the bottom-right corner

  • x3 – X coordinate of the bottom-left corner

  • y3 – Y coordinate of the bottom-left corner

x: additionnal points (handles used for rotation -- other handles
being used for rectangle resizing)

(x0, y0)------>(x1, y1)
    ↑             |
    |             |
    x             x
    |             |
    |             ↓
(x3, y3)<------(x2, y2)
get_rect() tuple[float, float, float, float, float, float, float, float][source]

Return the coordinates of the rectangle

Returns:

Coordinates of the rectangle

get_center() tuple[float, float][source]

Return center coordinates

Returns:

Center coordinates

move_point_to(handle: int, pos: tuple[float, float], ctrl: bool = False) None[source]

Move a handle as returned by hit_test to the new position

Parameters:
  • handle – Handle

  • pos – Position

  • ctrl – True if <Ctrl> button is being pressed, False otherwise

class plotpy.items.PointShape(x: float = 0.0, y: float = 0.0, shapeparam: ShapeParam = None)[source]

Point shape

Parameters:
  • x – X coordinate

  • y – Y coordinate

  • shapeparam – Shape parameters

set_pos(x: float, y: float) None[source]

Set the point coordinates to (x, y)

Parameters:
  • x – X coordinate

  • y – Y coordinate

get_pos() tuple[float, float][source]

Return the point coordinates

Returns:

Point coordinates

move_point_to(handle: int, pos: tuple[float, float], ctrl: bool = False) None[source]

Move a handle as returned by hit_test to the new position

Parameters:
  • handle – Handle

  • pos – Position

  • ctrl – True if <Ctrl> button is being pressed, False otherwise

boundingRect() QRectF[source]

Return the bounding rectangle of the shape

Returns:

Bounding rectangle of the shape

class plotpy.items.SegmentShape(x1: float = 0.0, y1: float = 0.0, x2: float = 0.0, y2: float = 0.0, shapeparam: ShapeParam = None)[source]

Segment shape

Parameters:
  • x1 – X coordinate of the first point

  • y1 – Y coordinate of the first point

  • x2 – X coordinate of the second point

  • y2 – Y coordinate of the second point

  • shapeparam – Shape parameters

set_rect(x1: float, y1: float, x2: float, y2: float) None[source]

Set the segment coordinates

Parameters:
  • x1 – X coordinate of the first point

  • y1 – Y coordinate of the first point

  • x2 – X coordinate of the second point

  • y2 – Y coordinate of the second point

get_rect() tuple[float, float, float, float][source]

Return the segment coordinates

Returns:

Segment coordinates as a tuple (x1, y1, x2, y2)

move_point_to(handle: int, pos: tuple[float, float], ctrl: bool = False) None[source]

Move a handle as returned by hit_test to the new position

Parameters:
  • handle – Handle

  • pos – Position

  • ctrl – True if <Ctrl> button is being pressed, False otherwise

class plotpy.items.EllipseShape(x1: float = 0.0, y1: float = 0.0, x2: float = 0.0, y2: float = 0.0, shapeparam: ShapeParam = None)[source]

Ellipse shape

Parameters:
  • x1 – X coordinate of the first point

  • y1 – Y coordinate of the first point

  • x2 – X coordinate of the second point

  • y2 – Y coordinate of the second point

  • shapeparam – Shape parameters

switch_to_ellipse()[source]

Switch to ellipse mode

switch_to_circle()[source]

Switch to circle mode

set_xdiameter(x0: float, y0: float, x1: float, y1: float) None[source]

Set the coordinates of the ellipse’s X-axis diameter

Parameters:
  • x0 – X coordinate of the first point

  • y0 – Y coordinate of the first point

  • x1 – X coordinate of the second point

  • y1 – Y coordinate of the second point

get_xdiameter() tuple[tuple[float, float], tuple[float, float]][source]

Return the coordinates of the ellipse’s X-axis diameter

Returns:

Tuple with two tuples of floats

set_ydiameter(x2: float, y2: float, x3: float, y3: float) None[source]

Set the coordinates of the ellipse’s Y-axis diameter

Parameters:
  • x2 – X coordinate of the first point

  • y2 – Y coordinate of the first point

  • x3 – X coordinate of the second point

  • y3 – Y coordinate of the second point

get_ydiameter() tuple[tuple[float, float], tuple[float, float]][source]

Return the coordinates of the ellipse’s Y-axis diameter

Returns:

Tuple with two tuples of floats

get_rect() tuple[float, float, float, float][source]

Get the bounding rectangle of the shape

Returns:

Tuple with four floats

Warning

This method is valid for circle only!

boundingRect() QRectF[source]

Return the bounding rectangle of the shape

Returns:

Bounding rectangle of the shape

get_center() tuple[float, float][source]

Return center coordinates

Returns:

Tuple with two floats (x, y)

set_rect(x0: float, y0: float, x1: float, y1: float) None[source]

Set the bounding rectangle of the shape

Parameters:
  • x0 – X coordinate of the first point

  • y0 – Y coordinate of the first point

  • x1 – X coordinate of the second point

  • y1 – Y coordinate of the second point

Warning

This method is valid for circle only!

compute_elements(xMap: qwt.scale_map.QwtScaleMap, yMap: qwt.scale_map.QwtScaleMap) tuple[QPolygonF, QLineF, QLineF, QRectF][source]

Return points, lines and ellipse rect

Parameters:
  • xMap – X axis scale map

  • yMap – Y axis scale map

Returns:

Tuple with four elements (points, line0, line1, rect)

hit_test(pos: QPointF) tuple[float, float, bool, None][source]

Return a tuple (distance, attach point, inside, other_object)

Parameters:

pos – Position

Returns:

Tuple with four elements: (distance, attach point, inside,

other_object).

Return type:

tuple

Description of the returned values:

  • distance: distance in pixels (canvas coordinates) to the closest

    attach point

  • attach point: handle of the attach point

  • inside: True if the mouse button has been clicked inside the object

  • other_object: if not None, reference of the object which will be

    considered as hit instead of self

draw(painter: QPainter, xMap: qwt.scale_map.QwtScaleMap, yMap: qwt.scale_map.QwtScaleMap, canvasRect: QRectF) None[source]

Draw the item

Parameters:
  • painter – Painter

  • xMap – X axis scale map

  • yMap – Y axis scale map

  • canvasRect – Canvas rectangle

get_xline() QLineF[source]

Get the X axis diameter

Returns:

X axis diameter

get_yline() QLineF[source]

Get the Y axis diameter

Returns:

Y axis diameter

move_point_to(handle: int, pos: tuple[float, float], ctrl: bool = False) None[source]

Move a handle as returned by hit_test to the new position

Parameters:
  • handle – Handle

  • pos – Position

  • ctrl – True if <Ctrl> button is being pressed, False otherwise

class plotpy.items.Axes(p0: tuple[float, float] = (0, 0), p1: tuple[float, float] = (0, 0), p2: tuple[float, float] = (0, 0), axesparam: AxesShapeParam = None, shapeparam: ShapeParam = None)[source]

Axes shape

Parameters:
  • p0 – First point (0,1)

  • p1 – Second point (1,1)

  • p2 – Third point (0,0)

  • axesparam – Axes parameters

  • shapeparam – Shape parameters

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

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

get_transform_matrix(dx: float = 1.0, dy: float = 1.0) ndarray[source]

Return the transformation matrix

Parameters:
  • dx – X scale

  • dy – Y scale

Returns:

Transformation matrix

set_rect(p0: tuple[float, float], p1: tuple[float, float], p2: tuple[float, float]) None[source]

Set the coordinates of the axes

Parameters:
  • p0 – First point (0,1)

  • p1 – Second point (1,1)

  • p2 – Third point (0,0)

set_style(section: str, option: str) None[source]

Set style for this item

Parameters:
  • section – Section

  • option – Option

move_point_to(handle: int, pos: tuple[float, float], ctrl: bool = False) None[source]

Move a handle as returned by hit_test to the new position

Parameters:
  • handle – Handle

  • pos – Position

  • ctrl – True if <Ctrl> button is being pressed, False otherwise

move_shape(old_pos: QPointF, new_pos: QPointF) None[source]

Translate the shape such that old_pos becomes new_pos in axis coordinates

Parameters:
  • old_pos – Old position

  • new_pos – New position

draw(painter: QPainter, xMap: qwt.scale_map.QwtScaleMap, yMap: qwt.scale_map.QwtScaleMap, canvasRect: QRectF) None[source]

Draw the item

Parameters:
  • painter – Painter

  • xMap – X axis scale map

  • yMap – Y axis scale map

  • canvasRect – Canvas rectangle

draw_arrow(painter: QPainter, xMap: qwt.scale_map.QwtScaleMap, yMap: qwt.scale_map.QwtScaleMap, p0: tuple[float, float], p1: tuple[float, float]) None[source]

Draw an arrow

Parameters:
  • painter – Painter

  • xMap – X axis scale map

  • yMap – Y axis scale map

  • p0 – First point

  • p1 – Second point

update_item_parameters() None[source]

Update item parameters (dataset) from object properties

get_item_parameters(itemparams: ItemParameters) None[source]

Appends datasets to the list of DataSets describing the parameters used to customize apearance of this item

Parameters:

itemparams – Item parameters

set_item_parameters(itemparams: ItemParameters) None[source]

Change the appearance of this item according to the parameter set provided

Parameters:

itemparams – Item parameters

class plotpy.items.XRangeSelection(_min: float | None = None, _max: float | None = None, shapeparam: RangeShapeParam | None = None)[source]

X range selection shape

Parameters:
  • _min – Minimum value

  • _max – Maximum value

  • shapeparam – Shape parameters

serialize(writer: HDF5Writer | INIWriter | JSONWriter) None[source]

Serialize object to HDF5 writer

Parameters:

writer – HDF5, INI or JSON writer

deserialize(reader: HDF5Reader | INIReader | JSONReader) None[source]

Deserialize object from HDF5 reader

Parameters:

reader – HDF5, INI or JSON reader

get_handles_pos() tuple[float, float, float][source]

Return the handles position

Returns:

Tuple with three elements (x0, x1, y).

draw(painter: QPainter, xMap: qwt.scale_map.QwtScaleMap, yMap: qwt.scale_map.QwtScaleMap, canvasRect: QRectF) None[source]

Draw the item

Parameters:
  • painter – Painter

  • xMap – X axis scale map

  • yMap – Y axis scale map

  • canvasRect – Canvas rectangle

hit_test(pos: QPointF) tuple[float, float, bool, None][source]

Return a tuple (distance, attach point, inside, other_object)

Parameters:

pos – Position

Returns:

Tuple with four elements: (distance, attach point, inside,

other_object).

Return type:

tuple

Description of the returned values:

  • distance: distance in pixels (canvas coordinates) to the closest

    attach point

  • attach point: handle of the attach point

  • inside: True if the mouse button has been clicked inside the object

  • other_object: if not None, reference of the object which will be

    considered as hit instead of self

move_local_point_to(handle: int, pos: QPointF, ctrl: bool = None) None[source]

Move a handle as returned by hit_test to the new position

Parameters:
  • handle – Handle

  • pos – Position

  • ctrl – True if <Ctrl> button is being pressed, False otherwise

move_point_to(handle: int, pos: tuple[float, float], ctrl: bool = False) None[source]

Move a handle as returned by hit_test to the new position

Parameters:
  • handle – Handle

  • pos – Position

  • ctrl – True if <Ctrl> button is being pressed, False otherwise

get_range() tuple[float, float][source]

Return the range

Returns:

Tuple with two elements (min, max).

set_range(_min: float, _max: float, dosignal: bool = True) None[source]

Set the range

Parameters:
  • _min – Minimum value

  • _max – Maximum value

  • dosignal – True to emit the SIG_RANGE_CHANGED signal

move_shape(old_pos: tuple[float, float], new_pos: tuple[float, float]) None[source]

Translate the shape such that old_pos becomes new_pos in axis coordinates

Parameters:
  • old_pos – Old position

  • new_pos – New position

update_item_parameters() None[source]

Update item parameters (dataset) from object properties

get_item_parameters(itemparams: ItemParameters) None[source]

Appends datasets to the list of DataSets describing the parameters used to customize apearance of this item

Parameters:

itemparams – Item parameters

set_item_parameters(itemparams: ItemParameters) None[source]

Change the appearance of this item according to the parameter set provided

Parameters:

itemparams – Item parameters

boundingRect() QRectF[source]

Return the bounding rectangle of the shape

Returns:

Bounding rectangle of the shape

class plotpy.items.Marker(label_cb: Callable | None = None, constraint_cb: Callable | None = None, markerparam: MarkerParam = None)[source]

Marker shape

Parameters:
  • label_cb – Label callback (must return a string, takes x and y as arguments)

  • constraint_cb – Constraint callback (must return a tuple (x, y), takes x and y as arguments)

  • markerparam – Marker parameters

Note

Marker class derives from QwtPlotMarker, which is a QwtPlotItem. That is why AbstractShape methods are re-implemented here.

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

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

draw(painter: QPainter, xMap: qwt.scale_map.QwtScaleMap, yMap: qwt.scale_map.QwtScaleMap, canvasRect: QRectF) None[source]

Draw the item

Parameters:
  • painter – Painter

  • xMap – X axis scale map

  • yMap – Y axis scale map

  • canvasRect – Canvas rectangle

set_selectable(state: bool) None[source]

Set item selectable state

Parameters:

state – True if item is selectable, False otherwise

set_resizable(state: bool) None[source]

Set item resizable state (or any action triggered when moving an handle, e.g. rotation)

Parameters:

state – True if item is resizable, False otherwise

set_movable(state: bool) None[source]

Set item movable state

Parameters:

state – True if item is movable, False otherwise

set_rotatable(state: bool) None[source]

Set item rotatable state

Parameters:

state – True if item is rotatable, False otherwise

can_select() bool[source]

Returns True if this item can be selected

Returns:

True if item can be selected, False otherwise

Return type:

bool

can_resize() bool[source]

Returns True if this item can be resized

Returns:

True if item can be resized, False otherwise

Return type:

bool

can_rotate() bool[source]

Returns True if this item can be rotated

Returns:

True if item can be rotated, False otherwise

Return type:

bool

can_move() bool[source]

Returns True if this item can be moved

Returns:

True if item can be moved, False otherwise

Return type:

bool

types() tuple[type[IItemType], ...][source]

Returns a group or category for this item. This should be a tuple of class objects inheriting from IItemType

Returns:

Tuple of class objects inheriting from IItemType

Return type:

tuple

set_readonly(state: bool) None[source]

Set object readonly state

Parameters:

state – True if object is readonly, False otherwise

is_readonly() bool[source]

Return object readonly state

Returns:

True if object is readonly, False otherwise

Return type:

bool

set_private(state: bool) None[source]

Set object as private

Parameters:

state – True if object is private, False otherwise

is_private() bool[source]

Return True if object is private

Returns:

True if object is private, False otherwise

Return type:

bool

select() None[source]

Select the object and eventually change its appearance to highlight the fact that it’s selected

unselect() None[source]

Unselect the object and eventually restore its original appearance to highlight the fact that it’s not selected anymore

hit_test(pos: QPointF) tuple[float, float, bool, None][source]

Return a tuple (distance, attach point, inside, other_object)

Parameters:

pos – Position

Returns:

Tuple with four elements: (distance, attach point, inside,

other_object).

Return type:

tuple

Description of the returned values:

  • distance: distance in pixels (canvas coordinates) to the closest

    attach point

  • attach point: handle of the attach point

  • inside: True if the mouse button has been clicked inside the object

  • other_object: if not None, reference of the object which will be

    considered as hit instead of self

update_item_parameters() None[source]

Update item parameters (dataset) from object properties

get_item_parameters(itemparams: ItemParameters) None[source]

Appends datasets to the list of DataSets describing the parameters used to customize apearance of this item

Parameters:

itemparams – Item parameters

set_item_parameters(itemparams)[source]

Change the appearance of this item according to the parameter set provided

params is a list of Datasets of the same types as those returned by get_item_parameters

move_local_point_to(handle: int, pos: QPointF, ctrl: bool = None) None[source]

Move a handle as returned by hit_test to the new position

Parameters:
  • handle – Handle

  • pos – Position

  • ctrl – True if <Ctrl> button is being pressed, False otherwise

move_local_shape(old_pos: QPointF, new_pos: QPointF) None[source]

Translate the shape such that old_pos becomes new_pos in canvas coordinates

Parameters:
  • old_pos – Old position

  • new_pos – New position

move_with_selection(delta_x: float, delta_y: float) None[source]

Translate the item together with other selected items

Parameters:
  • delta_x – Translation in plot coordinates along x-axis

  • delta_y – Translation in plot coordinates along y-axis

set_style(section: str, option: str) None[source]

Set style for this item

Parameters:
  • section – Section

  • option – Option

set_pos(x: float | None = None, y: float | None = None) None[source]

Set marker position

Parameters:
  • x – X value (if None, use current value)

  • y – Y value (if None, use current value)

get_pos() tuple[float, float][source]

Get marker position

Returns:

Tuple with two elements (x, y)

set_markerstyle(style: str | int | None) None[source]

Set marker style

Parameters:

style – Marker style

is_vertical() bool[source]

Is it a vertical cursor?

Returns:

True if this is a vertical cursor

is_horizontal() bool[source]

Is it a horizontal cursor?

Returns:

True if this is a horizontal cursor

center_handle(x: float, y: float) tuple[float, float][source]

Center cursor handle depending on marker style (|, -)

Parameters:
  • x – X value

  • y – Y value

Returns:

Tuple with two elements (x, y)

invalidate_plot() None[source]

Invalidate the plot to force a redraw

update_label() None[source]

Update label

class plotpy.items.RectangleSVGShape(x1: float = 0.0, y1: float = 0.0, x2: float = 0.0, y2: float = 0.0, svg_data: bytes | None = None, shapeparam: ShapeParam = None)[source]

Rectangle SVG shape

Parameters:
  • x1 – X coordinate of the top-left corner

  • y1 – Y coordinate of the top-left corner

  • x2 – X coordinate of the bottom-right corner

  • y2 – Y coordinate of the bottom-right corner

  • svg_data – SVG bytes

  • shapeparam – Shape parameters

set_data(svg_data: bytes) None[source]

Set SVG data

draw(painter: QPainter, xMap: QwtScaleMap, yMap: QwtScaleMap, canvasRect: QRectF) None[source]

Draw shape (reimplement shape.Shape.draw))

class plotpy.items.SquareSVGShape(x1: float = 0.0, y1: float = 0.0, x2: float = 0.0, y2: float = 0.0, svg_data: bytes | None = None, shapeparam: ShapeParam = None)[source]

Square SVG shape

Parameters:
  • svg_data – SVG bytes

  • x1 – X coordinate of the top-left corner

  • y1 – Y coordinate of the top-left corner

  • x2 – X coordinate of the bottom-right corner

  • y2 – Y coordinate of the bottom-right corner

  • shapeparam – Shape parameters

move_point_to(handle: int, pos: tuple[float], ctrl: bool = None)[source]

Reimplement RectangleShape.move_point_to

class plotpy.items.CircleSVGShape(x1: float = 0.0, y1: float = 0.0, x2: float = 0.0, y2: float = 0.0, svg_data: bytes | None = None, shapeparam: ShapeParam = None)[source]

Circle SVG shape

Parameters:
  • x1 – X coordinate of the top-left corner

  • y1 – Y coordinate of the top-left corner

  • x2 – X coordinate of the bottom-right corner

  • y2 – Y coordinate of the bottom-right corner

  • svg_data – SVG bytes

  • shapeparam – Shape parameters

set_data(svg_data: bytes) None[source]

Set SVG data

draw(painter: QPainter, xMap: QwtScaleMap, yMap: QwtScaleMap, canvasRect: QRect) None[source]

Draw shape (reimplement shape.Shape.draw))

Annotations

class plotpy.items.AnnotatedShape(annotationparam: AnnotationParam | None = None)[source]

Construct an annotated shape with properties set with annotationparam (see styles.AnnotationParam)

Parameters:

annotationparam – Annotation parameters

SHAPE_CLASS

alias of RectangleShape

types() tuple[type[IItemType], ...][source]

Returns a group or category for this item. This should be a tuple of class objects inheriting from IItemType

Returns:

Tuple of class objects inheriting from IItemType

Return type:

tuple

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

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

set_style(section: str, option: str) None[source]

Set style for this item

Parameters:
  • section – Section

  • option – Option

draw(painter: QPainter, xMap: qwt.scale_map.QwtScaleMap, yMap: qwt.scale_map.QwtScaleMap, canvasRect: QRectF) None[source]

Draw the item

Parameters:
  • painter – Painter

  • xMap – X axis scale map

  • yMap – Y axis scale map

  • canvasRect – Canvas rectangle

create_shape()[source]

Return the shape object associated to this annotated shape object

create_label() DataInfoLabel[source]

Return the label object associated to this annotated shape object

Returns:

Label object

is_label_visible() bool[source]

Return True if associated label is visible

Returns:

True if associated label is visible

set_label_visible(state: bool) None[source]

Set the annotated shape’s label visibility

Parameters:

state – True if label should be visible

update_label() None[source]

Update the annotated shape’s label contents

get_text() str[source]

Return text associated to current shape (see label.ObjectInfo)

Returns:

Text associated to current shape

x_to_str(x: float) str[source]

Convert x to a string (with associated unit and uncertainty)

Parameters:

x – X value

Returns:

Formatted string with x value

Return type:

str

y_to_str(y)[source]

Convert y to a string (with associated unit and uncertainty)

Parameters:

y – Y value

Returns:

Formatted string with x value

Return type:

str

get_center()[source]

Return shape center coordinates: (xc, yc)

get_tr_center()[source]

Return shape center coordinates after applying transform matrix

get_tr_center_str()[source]

Return center coordinates as a string (with units)

get_tr_size()[source]

Return shape size after applying transform matrix

get_tr_size_str()[source]

Return size as a string (with units)

get_infos() str[source]

Get informations on current shape

Returns:

Formatted string with informations on current shape

Return type:

str

set_label_position()[source]

Set label position, for instance based on shape position

apply_transform_matrix(x, y)[source]
Parameters:
  • x

  • y

Returns:

get_transformed_coords(handle1, handle2)[source]
Parameters:
  • handle1

  • handle2

Returns:

hit_test(pos: QPointF) tuple[float, float, bool, None][source]

Return a tuple (distance, attach point, inside, other_object)

Parameters:

pos – Position

Returns:

Tuple with four elements: (distance, attach point, inside,

other_object).

Return type:

tuple

Description of the returned values:

  • distance: distance in pixels (canvas coordinates) to the closest

    attach point

  • attach point: handle of the attach point

  • inside: True if the mouse button has been clicked inside the object

  • other_object: if not None, reference of the object which will be

    considered as hit instead of self

move_point_to(handle: int, pos: tuple[float, float], ctrl: bool = False) None[source]

Move a handle as returned by hit_test to the new position

Parameters:
  • handle – Handle

  • pos – Position

  • ctrl – True if <Ctrl> button is being pressed, False otherwise

move_shape(old_pos: QPointF, new_pos: QPointF) None[source]

Translate the shape such that old_pos becomes new_pos in axis coordinates

Parameters:
  • old_pos – Old position

  • new_pos – New position

move_local_shape(old_pos: QPointF, new_pos: QPointF) None[source]

Translate the shape such that old_pos becomes new_pos in canvas coordinates

Parameters:
  • old_pos – Old position

  • new_pos – New position

move_with_selection(delta_x: float, delta_y: float) None[source]

Translate the item together with other selected items

Parameters:
  • delta_x – Translation in plot coordinates along x-axis

  • delta_y – Translation in plot coordinates along y-axis

select() None[source]

Select the object and eventually change its appearance to highlight the fact that it’s selected

unselect() None[source]

Unselect the object and eventually restore its original appearance to highlight the fact that it’s not selected anymore

get_item_parameters(itemparams: ItemParameters) None[source]

Appends datasets to the list of DataSets describing the parameters used to customize apearance of this item

Parameters:

itemparams – Item parameters

set_item_parameters(itemparams: ItemParameters) None[source]

Change the appearance of this item according to the parameter set provided

Parameters:

itemparams – Item parameters

is_empty() bool[source]

Return True if the item is empty

Returns:

True if the item is empty, False otherwise

boundingRect() QRectF[source]

Return the bounding rectangle of the shape

Returns:

Bounding rectangle of the shape

class plotpy.items.AnnotatedPoint(x=0, y=0, annotationparam=None)[source]

Construct an annotated point at coordinates (x, y) with properties set with annotationparam (see styles.AnnotationParam)

SHAPE_CLASS

alias of PointShape

set_pos(x, y)[source]

Set the point coordinates to (x, y)

get_pos()[source]

Return the point coordinates

create_shape()[source]

Return the shape object associated to this annotated shape object

set_label_position()[source]

Set label position, for instance based on shape position

get_infos() str[source]

Get informations on current shape

Returns:

Formatted string with informations on current shape

Return type:

str

class plotpy.items.AnnotatedSegment(x1=0, y1=0, x2=0, y2=0, annotationparam=None)[source]

Construct an annotated segment between coordinates (x1, y1) and (x2, y2) with properties set with annotationparam (see styles.AnnotationParam)

SHAPE_CLASS

alias of SegmentShape

set_rect(x1, y1, x2, y2)[source]

Set the coordinates of the shape’s top-left corner to (x1, y1), and of its bottom-right corner to (x2, y2).

get_rect()[source]

Return the coordinates of the shape’s top-left and bottom-right corners

get_tr_length()[source]

Return segment length after applying transform matrix

get_tr_center()[source]

Return segment position (middle) after applying transform matrix

set_label_position()[source]

Set label position, for instance based on shape position

get_infos() str[source]

Get informations on current shape

Returns:

Formatted string with informations on current shape

Return type:

str

class plotpy.items.AnnotatedRectangle(x1=0, y1=0, x2=0, y2=0, annotationparam=None)[source]

Construct an annotated rectangle between coordinates (x1, y1) and (x2, y2) with properties set with annotationparam (see styles.AnnotationParam)

SHAPE_CLASS

alias of RectangleShape

set_rect(x1, y1, x2, y2)[source]

Set the coordinates of the shape’s top-left corner to (x1, y1), and of its bottom-right corner to (x2, y2).

get_rect() tuple[float, float, float, float][source]

Return the coordinates of the shape’s top-left and bottom-right corners

set_label_position()[source]

Set label position, for instance based on shape position

get_tr_center()[source]

Return shape center coordinates after applying transform matrix

get_tr_size()[source]

Return shape size after applying transform matrix

get_infos() str[source]

Get informations on current shape

Returns:

Formatted string with informations on current shape

Return type:

str

class plotpy.items.AnnotatedObliqueRectangle(x0=0, y0=0, x1=0, y1=0, x2=0, y2=0, x3=0, y3=0, annotationparam=None)[source]

Construct an annotated oblique rectangle between coordinates (x0, y0), (x1, y1), (x2, y2) and (x3, y3) with properties set with annotationparam (see styles.AnnotationParam)

SHAPE_CLASS

alias of ObliqueRectangleShape

get_tr_angle()[source]

Return X-diameter angle with horizontal direction, after applying transform matrix

get_bounding_rect_coords() tuple[float, float, float, float][source]

Return bounding rectangle coordinates (in plot coordinates)

Returns:

Bounding rectangle coordinates (in plot coordinates)

create_shape()[source]

Return the shape object associated to this annotated shape object

set_label_position()[source]

Set label position, for instance based on shape position

set_rect(x0, y0, x1, y1, x2, y2, x3, y3)[source]

Set the rectangle corners coordinates:

(x0, y0): top-left corner (x1, y1): top-right corner (x2, y2): bottom-right corner (x3, y3): bottom-left corner

x: additionnal points

(x0, y0)------>(x1, y1)
    ↑             |
    |             |
    x             x
    |             |
    |             ↓
(x3, y3)<------(x2, y2)
get_tr_size()[source]

Return shape size after applying transform matrix

get_infos() str[source]

Get informations on current shape

Returns:

Formatted string with informations on current shape

Return type:

str

get_tr_center()[source]

Return shape center coordinates after applying transform matrix

class plotpy.items.AnnotatedEllipse(x1=0, y1=0, x2=0, y2=0, annotationparam=None)[source]

Construct an annotated ellipse with X-axis diameter between coordinates (x1, y1) and (x2, y2) and properties set with annotationparam (see styles.AnnotationParam)

SHAPE_CLASS

alias of EllipseShape

switch_to_ellipse()[source]

Switch to ellipse mode

switch_to_circle()[source]

Switch to circle mode

set_xdiameter(x0, y0, x1, y1)[source]

Set the coordinates of the ellipse’s X-axis diameter Warning: transform matrix is not applied here

get_xdiameter()[source]

Return the coordinates of the ellipse’s X-axis diameter Warning: transform matrix is not applied here

set_ydiameter(x2, y2, x3, y3)[source]

Set the coordinates of the ellipse’s Y-axis diameter Warning: transform matrix is not applied here

get_ydiameter()[source]

Return the coordinates of the ellipse’s Y-axis diameter Warning: transform matrix is not applied here

get_rect()[source]
Returns:

set_rect(x0, y0, x1, y1)[source]
Parameters:
  • x0

  • y0

  • x1

  • y1

get_tr_angle()[source]

Return X-diameter angle with horizontal direction, after applying transform matrix

set_label_position()[source]

Set label position, for instance based on shape position

get_tr_center()[source]

Return center coordinates: (xc, yc)

get_tr_size()[source]

Return shape size after applying transform matrix

get_infos() str[source]

Get informations on current shape

Returns:

Formatted string with informations on current shape

Return type:

str

class plotpy.items.AnnotatedCircle(x1=0, y1=0, x2=0, y2=0, annotationparam=None)[source]

Construct an annotated circle with diameter between coordinates (x1, y1) and (x2, y2) and properties set with annotationparam (see styles.AnnotationParam)

get_tr_diameter()[source]

Return circle diameter after applying transform matrix

get_infos() str[source]

Get informations on current shape

Returns:

Formatted string with informations on current shape

Return type:

str

set_rect(x0, y0, x1, y1)[source]
Parameters:
  • x0

  • y0

  • x1

  • y1

Labels

class plotpy.items.LabelItem(text: str | None = None, labelparam: LabelParam | None = None)[source]

Label plot item

Parameters:
  • text – Text

  • labelparam – Label parameters

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

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

types() tuple[type[IItemType], ...][source]

Returns a group or category for this item. This should be a tuple of class objects inheriting from IItemType

Returns:

Tuple of class objects inheriting from IItemType

Return type:

tuple

set_pos(x: float, y: float) None[source]

Set position

Parameters:
  • x – X coordinate

  • y – Y coordinate

get_plain_text() str[source]

Get plain text

Returns:

Plain text

Return type:

str

set_text(text: str | None = None) None[source]

Set text

Parameters:

text – Text

set_text_style(font: QFont | None = None, color: str | None = None) None[source]

Set label text style

Parameters:
  • font – Font

  • color – Color

get_text_rect() QRectF[source]

Return the text rectangle

Returns:

Text rectangle

update_text() None[source]

Update text

draw(painter: QPainter, xMap: qwt.scale_map.QwtScaleMap, yMap: qwt.scale_map.QwtScaleMap, canvasRect: QRectF) None[source]

Draw the item

Parameters:
  • painter – Painter

  • xMap – X axis scale map

  • yMap – Y axis scale map

  • canvasRect – Canvas rectangle

class plotpy.items.LegendBoxItem(labelparam: LabelParam = None)[source]

Legend box plot item

Parameters:

labelparam – Label parameters

types() tuple[type[IItemType], ...][source]

Returns a group or category for this item. This should be a tuple of class objects inheriting from IItemType

Returns:

Tuple of class objects inheriting from IItemType

Return type:

tuple

get_legend_items() list[tuple[QTextDocument, QPen, QBrush, qwt.symbol.QwtSymbol]][source]

Return the legend items

Returns:

List of legend items (text, pen, brush, symbol)

Return type:

list

include_item(item: Any) bool[source]

Include item in legend box?

Parameters:

item – Item

Returns:

True if item is included, False otherwise

get_legend_size(legenditems: list[tuple]) tuple[float, float, float, float][source]

Return the legend size

Parameters:

legenditems – Legend items

Returns:

Tuple with four elements: (TW, TH, width, height)

Return type:

tuple

set_text_style(font: QFont | None = None, color: str | None = None) None[source]

Set label text style

Parameters:
  • font – Font

  • color – Color

get_text_rect() QRectF[source]

Return the text rectangle

Returns:

Text rectangle

draw(painter: QPainter, xMap: qwt.scale_map.QwtScaleMap, yMap: qwt.scale_map.QwtScaleMap, canvasRect: QRectF) None[source]

Draw the item

Parameters:
  • painter – Painter

  • xMap – X axis scale map

  • yMap – Y axis scale map

  • canvasRect – Canvas rectangle

click_inside(locx: float, locy: float) tuple[float, float, bool, type][source]

Called when the mouse button is clicked inside the object

Parameters:
  • locx – Local x coordinate

  • locy – Local y coordinate

Returns:

Tuple with four elements: (distance, attach point, inside,

other_object).

Return type:

tuple

update_item_parameters() None[source]

Update item parameters (dataset) from object properties

get_item_parameters(itemparams: ItemParameters) None[source]

Appends datasets to the list of DataSets describing the parameters used to customize apearance of this item

Parameters:

itemparams – Item parameters

set_item_parameters(itemparams: ItemParameters) None[source]

Change the appearance of this item according to the parameter set provided

Parameters:

itemparams – Item parameters

class plotpy.items.SelectedLegendBoxItem(dataset: LabelParam = None, itemlist: list[Any] | None = None)[source]

Selected legend box plot item

Parameters:
  • labelparam – Label parameters

  • itemlist – List of items

include_item(item: Any) bool[source]

Include item in legend box?

Parameters:

item – Item

Returns:

True if item is included, False otherwise

add_item(item: Any) None[source]

Add item

Parameters:

item – Item

class plotpy.items.RangeComputation(label: str, curve: CurveItem, xrangeselection: XRangeSelection, function: Callable | None = None)[source]

ObjectInfo showing curve computations relative to a XRangeSelection shape

Parameters:
  • label – formatted string

  • curve – CurveItem object

  • xrangeselection – XRangeSelection object

  • function – input arguments are x, y arrays (extraction of arrays corresponding to the xrangeselection X-axis range)

set_curve(curve: CurveItem) None[source]

Set curve item

Parameters:

curve – Curve item

get_text() str[source]

Return the text to be displayed

class plotpy.items.RangeComputation2d(label: str, image: ImageItem, rect: RectangleShape, function: Callable)[source]

ObjectInfo showing image computations relative to a rectangular area

Parameters:
  • label – formatted string

  • image – ImageItem object

  • rect – Rectangular area

  • function – input arguments are x, y, z arrays (extraction of arrays corresponding to the rectangular area)

get_text() str[source]

Return the text to be displayed

class plotpy.items.DataInfoLabel(labelparam: LabelParam | None = None, infos: list[Any] | None = None)[source]

Label item displaying informations relative to an annotation

Parameters:
  • labelparam – Label parameters

  • infos – List of objects implementing the get_text method

types() tuple[type[IItemType], ...][source]

Returns a group or category for this item. This should be a tuple of class objects inheriting from IItemType

Returns:

Tuple of class objects inheriting from IItemType

Return type:

tuple

update_text()[source]

Update text

class plotpy.items.ObjectInfo[source]

Base class for objects used to format text labels

get_text() str[source]

Return the text to be displayed