magicclass.widgets.qtgraph package

Submodules

magicclass.widgets.qtgraph.graph_items module

class magicclass.widgets.qtgraph.graph_items.Curve(x, y, name=None, **kwargs)[source]

Bases: magicclass.widgets.qtgraph.graph_items.PlotDataItem

base_item

alias of pyqtgraph.graphicsItems.PlotCurveItem.PlotCurveItem

class magicclass.widgets.qtgraph.graph_items.PlotDataItem(x, y, name=None, **kwargs)[source]

Bases: object

add(points: np.ndarray | Sequence, **kwargs)[source]
base_item: type[pg.PlotCurveItem | pg.ScatterPlotItem]
property color: numpy.ndarray
property linestyle
property linewidth
property ls
property lw
property ndata: int
remove(i: int | Sequence[int])[source]
property visible
property xdata: numpy.ndarray
property ydata: numpy.ndarray
class magicclass.widgets.qtgraph.graph_items.Scatter(x, y, name=None, **kwargs)[source]

Bases: magicclass.widgets.qtgraph.graph_items.PlotDataItem

base_item

alias of pyqtgraph.graphicsItems.ScatterPlotItem.ScatterPlotItem

property symbol
property symbol_size
class magicclass.widgets.qtgraph.graph_items.TextOverlay(text: str, color: Sequence[float] | str)[source]

Bases: object

property color
property text
update(**kwargs)[source]
property visible

magicclass.widgets.qtgraph.mouse_event module

class magicclass.widgets.qtgraph.mouse_event.Button(value)[source]

Bases: magicclass.widgets.qtgraph.mouse_event.strEnum

An enumeration.

left = 'left'
middle = 'middle'
right = 'right'
class magicclass.widgets.qtgraph.mouse_event.Modifier(value)[source]

Bases: magicclass.widgets.qtgraph.mouse_event.strEnum

An enumeration.

alt = 'alt'
control = 'control'
shift = 'shift'
class magicclass.widgets.qtgraph.mouse_event.MouseClickEvent(event: pyqtgraph.GraphicsScene.mouseEvents.MouseClickEvent, coord_item)[source]

Bases: pyqtgraph.GraphicsScene.mouseEvents.MouseClickEvent

buttons()[source]

Return the buttons currently pressed on the mouse. (see QGraphicsSceneMouseEvent::buttons in the Qt documentation)

lastPos()[source]

Return the previous position of the mouse in the coordinate system of the item that the event was delivered to.

modifiers()[source]

Return any keyboard modifiers currently pressed. (see QGraphicsSceneMouseEvent::modifiers in the Qt documentation)

pos()[source]

Return the current position of the mouse in the coordinate system of the item that the event was delivered to.

class magicclass.widgets.qtgraph.mouse_event.strEnum(value)[source]

Bases: enum.Enum

An enumeration.

magicclass.widgets.qtgraph.qt_graph module

class magicclass.widgets.qtgraph.qt_graph.HasPlotItem[source]

Bases: object

add_curve(x: Sequence[float], **kwargs)[source]
add_curve(x: Sequence[float], y: Sequence[float], **kwargs)

Add line plot like plt.plot(x, y)

Parameters
  • x (array-like, optional) -- X data.

  • y (array-like, optional) -- Y data.

  • kwargs -- color, lw (line width), ls (linestyle) is supported now.

add_scatter(x: Sequence[float], **kwargs)[source]
add_scatter(x: Sequence[float], y: Sequence[float], **kwargs)

Add scatter plot like plt.scatter(x, y)

Parameters
  • x (array-like, optional) -- X data.

  • y (array-like, optional) -- Y data.

  • kwargs -- color, lw (line width), ls (linestyle) is supported now.

property layers: magicclass.widgets.qtgraph.qt_graph.LayerList
remove_item(item: PlotDataItem | int | str)[source]
class magicclass.widgets.qtgraph.qt_graph.LayerList(parent: magicclass.widgets.qtgraph.qt_graph.HasPlotItem)[source]

Bases: object

append(item: magicclass.widgets.qtgraph.graph_items.PlotDataItem)[source]
clear()[source]
class magicclass.widgets.qtgraph.qt_graph.QtImageCanvas(image: Optional[numpy.ndarray] = None, cmap=None, contrast_limits: Optional[tuple[float, float]] = None, show_hist: bool = True, show_button: bool = True, **kwargs)[source]

Bases: magicclass.widgets.utils.FreeWidget, magicclass.widgets.qtgraph.qt_graph.HasPlotItem

property cmap

Color map

property contrast_limits: tuple[float, float]

Contrast limits of image

property image: np.ndarray | None

Image data

property interactive: bool

Mouse interactivity

show_button(visible: bool = True)[source]

Set visibility of ROI/Norm buttons.

Parameters

visible (bool) -- Visibility of ROI/Norm buttons

show_hist(visible: bool = True)[source]

Set visibility of intensity histogram.

Parameters

visible (bool) -- Visibility of histogram

property text_overlay: magicclass.widgets.qtgraph.graph_items.TextOverlay

Text overlay on the image.

property view_range: list[list[float, float]]

Range of image (edge coordinates of canvas)

class magicclass.widgets.qtgraph.qt_graph.QtPlotCanvas(region_visible=False, **kwargs)[source]

Bases: magicclass.widgets.utils.FreeWidget, magicclass.widgets.qtgraph.qt_graph.HasPlotItem

A 1-D data viewer that have similar API as napari Viewer.

property interactive: bool

Mouse interactivity

property region: tuple[float, float]

Get the limits of linear region.

region_changed
property region_visible: bool

Linear region visibility.

property xlabel

Label of X-axis.

property xlim

Range limits of X-axis.

property ylabel: str

Label of Y-axis.

property ylim

Range limits of Y-axis.

Module contents

PyQtGraph wrapper classes.

QtPlotCanvas can treat line plots and scatter plots as "layers" and has similar API as napari.Viewer and matplotlib:

from magicclass.widgets import QtPlotCanvas

canvas = QtPlotCanvas()
canvas.add_curve(np.random.random(100), color="r")
canvas.add_scatter(np.random.random(100), ls=":")
canvas.layers[1].visible = False
canvas.interactive = False
canvas.show()

QtImageCanvas is also designed in a similar way as QtPlotCanvas but aims at 2D image visualization.

from magicclass.widgets import QtImageCanvas

image = np.random.random((128, 128))
canvas = QtImageCanvas(image)
canvas.show()
class magicclass.widgets.qtgraph.QtImageCanvas(image: Optional[numpy.ndarray] = None, cmap=None, contrast_limits: Optional[tuple[float, float]] = None, show_hist: bool = True, show_button: bool = True, **kwargs)[source]

Bases: magicclass.widgets.utils.FreeWidget, magicclass.widgets.qtgraph.qt_graph.HasPlotItem

property cmap

Color map

property contrast_limits: tuple[float, float]

Contrast limits of image

property image: np.ndarray | None

Image data

property interactive: bool

Mouse interactivity

show_button(visible: bool = True)[source]

Set visibility of ROI/Norm buttons.

Parameters

visible (bool) -- Visibility of ROI/Norm buttons

show_hist(visible: bool = True)[source]

Set visibility of intensity histogram.

Parameters

visible (bool) -- Visibility of histogram

property text_overlay: magicclass.widgets.qtgraph.graph_items.TextOverlay

Text overlay on the image.

property view_range: list[list[float, float]]

Range of image (edge coordinates of canvas)

class magicclass.widgets.qtgraph.QtPlotCanvas(region_visible=False, **kwargs)[source]

Bases: magicclass.widgets.utils.FreeWidget, magicclass.widgets.qtgraph.qt_graph.HasPlotItem

A 1-D data viewer that have similar API as napari Viewer.

property interactive: bool

Mouse interactivity

name: str
property region: tuple[float, float]

Get the limits of linear region.

region_changed
property region_visible: bool

Linear region visibility.

property xlabel

Label of X-axis.

property xlim

Range limits of X-axis.

property ylabel: str

Label of Y-axis.

property ylim

Range limits of Y-axis.