magicclass.ext.pyqtgraph package¶
Subpackages¶
Submodules¶
magicclass.ext.pyqtgraph.components module¶
- class magicclass.ext.pyqtgraph.components.GraphicComponent[source]¶
Bases:
object
- native: pyqtgraph.graphicsItems.GraphicsObject.GraphicsObject¶
- property visible: bool¶
Linear region visibility.
- class magicclass.ext.pyqtgraph.components.Legend(offset=(0, 0))[source]¶
Bases:
magicclass.ext.pyqtgraph.components.GraphicComponent
- property background_color¶
Background color.
- property border¶
Border color.
- property color¶
Text color.
- native: pyqtgraph.graphicsItems.LegendItem.LegendItem¶
- property size: int¶
Text size.
- class magicclass.ext.pyqtgraph.components.Region[source]¶
Bases:
magicclass.ext.pyqtgraph.components.GraphicComponent
A linear region with magicgui-like API
- changed¶
- property color¶
- property enabled: bool¶
- native: pyqtgraph.graphicsItems.LinearRegionItem.LinearRegionItem¶
- property value: tuple[float, float]¶
Get the limits of linear region.
- class magicclass.ext.pyqtgraph.components.Roi(pos=(0, 0))[source]¶
Bases:
magicclass.ext.pyqtgraph.components.GraphicComponent
- property border¶
- native: pyqtgraph.graphicsItems.ROI.ROI¶
- class magicclass.ext.pyqtgraph.components.ScaleBar[source]¶
Bases:
magicclass.ext.pyqtgraph.components.GraphicComponent
A scale bar with napari-like API
- property color¶
- native: pyqtgraph.graphicsItems.ScaleBar.ScaleBar¶
- property unit: str¶
- class magicclass.ext.pyqtgraph.components.TextItem(text: str, color: Sequence[float] | str, anchor=(0, 0), angle: float = 0)[source]¶
Bases:
magicclass.ext.pyqtgraph.components.GraphicComponent
A text item with napari-like API.
- property anchor: numpy.ndarray¶
- property background_color¶
- property border¶
- property color¶
- native: pyqtgraph.graphicsItems.TextItem.TextItem¶
- property pos: numpy.ndarray¶
- property text¶
magicclass.ext.pyqtgraph.graph_items module¶
- class magicclass.ext.pyqtgraph.graph_items.BarPlot(x, y, face_color=None, edge_color=None, width: float = 0.6, name: str | None = None, lw: float = 1, ls: str = '-')[source]¶
Bases:
magicclass.ext.pyqtgraph.graph_items.PlotDataLayer
- property edge_color: numpy.ndarray¶
Edge color of the data.
- property face_color: numpy.ndarray¶
Face color of the data.
- native: pg.BarGraphItem¶
- property xdata: numpy.ndarray¶
- property ydata: numpy.ndarray¶
- class magicclass.ext.pyqtgraph.graph_items.Curve(x, y, face_color=None, edge_color=None, size: float = 7, name: str | None = None, lw: float = 1, ls: str = '-', symbol=None)[source]¶
Bases:
magicclass.ext.pyqtgraph.graph_items.PlotDataLayer
- property edge_color: numpy.ndarray¶
Edge color of the data.
- property face_color: numpy.ndarray¶
Face color of the data.
- native: pg.PlotDataItem¶
- property size¶
- property symbol¶
- class magicclass.ext.pyqtgraph.graph_items.FillBetween(x, y1, y2, face_color=None, edge_color=None, name: str | None = None, lw: float = 1, ls: str = '-')[source]¶
Bases:
magicclass.ext.pyqtgraph.graph_items.PlotDataLayer
- property edge_color: numpy.ndarray¶
Edge color of the data.
- property face_color: numpy.ndarray¶
Face color of the data.
- property linestyle¶
Line style.
- property linewidth¶
Line width.
- property ls¶
Line style.
- property lw¶
Line width.
- property name: str¶
- native: pg.FillBetweenItem¶
- class magicclass.ext.pyqtgraph.graph_items.Histogram(data, bins: int | Sequence | str = 10, range=None, density: bool = False, face_color=None, edge_color=None, name: str | None = None, lw: float = 1, ls: str = '-')[source]¶
Bases:
magicclass.ext.pyqtgraph.graph_items.PlotDataLayer
- native: pg.ScatterPlotItem¶
- class magicclass.ext.pyqtgraph.graph_items.InfLine(pos, angle, edge_color=None, name: str | None = None, lw: float = 1, ls: str = '-')[source]¶
Bases:
magicclass.ext.pyqtgraph.graph_items.LayerItem
- property angle: float¶
Angle of the line in degree.
- property color: numpy.ndarray¶
- property edge_color: numpy.ndarray¶
- property intercept: float¶
Y-intercept of the line.
- property linestyle¶
Line style.
- property linewidth¶
Line width.
- property ls¶
Line style.
- property lw¶
Line width.
- property name¶
- native: pyqtgraph.graphicsItems.InfiniteLine.InfiniteLine¶
- property pos: numpy.ndarray¶
- property slope: float¶
Slope of the line.
- class magicclass.ext.pyqtgraph.graph_items.LayerItem[source]¶
Bases:
object
- native: pyqtgraph.graphicsItems.GraphicsItem.GraphicsItem¶
- property visible¶
Visibility of data.
- property zorder: float¶
Z-order of item. Item with larger z will be displayed on the top.
- class magicclass.ext.pyqtgraph.graph_items.PlotDataLayer[source]¶
Bases:
magicclass.ext.pyqtgraph.graph_items.LayerItem
- property color¶
- property edge_color: numpy.ndarray¶
Edge color of the data.
- property face_color: numpy.ndarray¶
Face color of the data.
- property linestyle¶
Line style.
- property linewidth¶
Line width.
- property ls¶
Line style.
- property lw¶
Line width.
- property name: str¶
- native: pg.PlotCurveItem | pg.ScatterPlotItem¶
- property ndata: int¶
- property xdata: numpy.ndarray¶
- property ydata: numpy.ndarray¶
- class magicclass.ext.pyqtgraph.graph_items.Scatter(x, y, face_color=None, edge_color=None, size: float = 7, name: str | None = None, lw: float = 1, ls: str = '-', symbol='o')[source]¶
Bases:
magicclass.ext.pyqtgraph.graph_items.PlotDataLayer
- native: pg.ScatterPlotItem¶
- property size¶
- property symbol¶
- class magicclass.ext.pyqtgraph.graph_items.TextGroup(x: Sequence[float], y: Sequence[float], texts: Sequence[str], color=None, name: Optional[str] = None)[source]¶
Bases:
magicclass.ext.pyqtgraph.graph_items.LayerItem
- property anchor: numpy.ndarray¶
Text anchor position.
- property background_color: numpy.ndarray¶
Text background color.
- property border: numpy.ndarray¶
Border color of text bounding box.
- property color: numpy.ndarray¶
Text color.
- native: pyqtgraph.graphicsItems.GraphicsItem.GraphicsItem¶
- property text: str | list[str]¶
Text string.
- property text_items: list[pyqtgraph.graphicsItems.TextItem.TextItem]¶
- property xdata: numpy.ndarray¶
- property ydata: numpy.ndarray¶
- class magicclass.ext.pyqtgraph.graph_items.TextItemView(textitem: pg.TextItem | list[pg.TextItem])[source]¶
Bases:
object
- property anchor: numpy.ndarray¶
Text anchor position.
- property background_color: numpy.ndarray¶
Text background color.
- property border: numpy.ndarray¶
Border color of text bounding box.
- property color: numpy.ndarray¶
Text color.
- property text: str | list[str]¶
Text string.
magicclass.ext.pyqtgraph.mouse_event module¶
- class magicclass.ext.pyqtgraph.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.
magicclass.ext.pyqtgraph.widgets module¶
- class magicclass.ext.pyqtgraph.widgets.HasBackground(layout='vertical', **kwargs)[source]¶
Bases:
magicclass.widgets.utils.FreeWidget
- property background_color¶
- class magicclass.ext.pyqtgraph.widgets.HasDataItems[source]¶
Bases:
object
- add_bar(x: Sequence[float], **kwargs)[source]¶
- add_bar(x: Sequence[float], y: Sequence[float], **kwargs)
Add a bar plot like
plt.bar(x, y)
.- Parameters
x (array-like) -- X data.
y (array-like) -- Y data.
width (float, default is 0.6) -- Width of each bar.
face_color (str or array-like, optional) -- Face color of plot. Graphic object will be filled with this color.
edge_color (str or array-like, optional) -- Edge color of plot.
color (str or array-like, optional) -- Set face color and edge color at the same time.
name (str, optional) -- Object name of the plot item.
lw (float, default is 1.0) -- Line width of edge.
ls (str, default is "-") -- Line style of edge. One of "-", "--", ":" or "-.".
- Returns
A plot item of the bar plot.
- Return type
- add_curve(x: Sequence[float], **kwargs)[source]¶
- add_curve(x: Sequence[float], y: Sequence[float], **kwargs)
Add a line plot like
plt.plot(x, y)
.- Parameters
x (array-like) -- X data.
y (array-like) -- Y data.
face_color (str or array-like, optional) -- Face color of plot. Graphic object will be filled with this color.
edge_color (str or array-like, optional) -- Edge color of plot.
color (str or array-like, optional) -- Set face color and edge color at the same time.
size (float, default is 7) -- Symbol size.
name (str, optional) -- Object name of the plot item.
lw (float, default is 1.0) -- Line width of edge.
ls (str, default is "-") -- Line style of edge. One of "-", "--", ":" or "-.".
symbol (str, optional) -- Symbol style. Currently supports circle ("o"), cross ("+", "x"), star ("*"), square ("s", "D") triangle ("^", "<", "v", ">") and others that
pyqtgraph
supports.
- Returns
A plot item of a curve.
- Return type
- add_fillbetween(x: Sequence[float], **kwargs)[source]¶
- add_fillbetween(x: Sequence[float], y: Sequence[float], **kwargs)
- add_hist(data: Sequence[float], bins: int | Sequence | str = 10, range=None, density: bool = False, face_color=None, edge_color=None, color=None, name: str | None = None, lw: float = 1, ls: str = '-')[source]¶
Add histogram like
plt.hist(data)
.- Parameters
data (array-like) -- Data for histogram constrction.
bins (int, sequence of float or str, default is 10) -- Bin numbers. See
np.histogram
for detail.range (two floats, optional) -- Bin ranges. See
np.histogram
for detail.density (bool, default is False) -- If true, plot the density instead of the counts. See
np.histogram
for detail.face_color (str or array-like, optional) -- Face color of plot. Graphic object will be filled with this color.
edge_color (str or array-like, optional) -- Edge color of plot.
color (str or array-like, optional) -- Set face color and edge color at the same time.
name (str, optional) -- Object name of the plot item.
lw (float, default is 1.0) -- Line width of edge.
ls (str, default is "-") -- Line style of edge. One of "-", "--", ":" or "-.".
- Returns
A plot item of the histogram.
- Return type
- add_infline(slope: float, intercept: float, color=None, name: str | None = None, lw: float = 1, ls: str = '-')[source]¶
- add_infline(pos: tuple[float, float], degree: float, color=None, name: str | None = None, lw: float = 1, ls: str = '-')
- 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) -- X data.
y (array-like) -- Y data.
face_color (str or array-like, optional) -- Face color of plot. Graphic object will be filled with this color.
edge_color (str or array-like, optional) -- Edge color of plot.
color (str or array-like, optional) -- Set face color and edge color at the same time.
size (float, default is 7) -- Symbol size.
name (str, optional) -- Object name of the plot item.
lw (float, default is 1.0) -- Line width of edge.
ls (str, default is "-") -- Line style of edge. One of "-", "--", ":" or "-.".
symbol (str, optional) -- Symbol style. Currently supports circle ("o"), cross ("+", "x"), star ("*"), square ("s", "D") triangle ("^", "<", "v", ">") and others that
pyqtgraph
supports.
- Returns
A plot item of the scatter plot.
- Return type
- add_text(x: float, y: float, text: str, **kwargs)[source]¶
- add_text(x: Sequence[float], y: Sequence[float], text: Sequence[str], **kwargs)
- property layers: magicclass.ext.pyqtgraph.widgets.LayerList¶
- class magicclass.ext.pyqtgraph.widgets.HasViewBox(viewbox: pyqtgraph.graphicsItems.ViewBox.ViewBox.ViewBox)[source]¶
Bases:
magicclass.ext.pyqtgraph.widgets.HasDataItems
- property border¶
- property enabled: bool¶
Mouse interactivity
- property interactive: bool¶
Mouse interactivity
- property xlim¶
Range limits of X-axis.
- property ylim¶
Range limits of Y-axis.
- class magicclass.ext.pyqtgraph.widgets.ImageItem(viewbox: pg.ViewBox | None = None, lock_contrast_limits: bool = False)[source]¶
Bases:
magicclass.ext.pyqtgraph.widgets.HasViewBox
- property cmap¶
Color map
- property contrast_limits: list[float, float]¶
Contrast limits of image
- property image: np.ndarray | None¶
Image data
- property lock_contrast_limits¶
- property scale_bar: magicclass.ext.pyqtgraph.components.ScaleBar¶
Scale bar on the image.
- property text_overlay: magicclass.ext.pyqtgraph.components.TextItem¶
Text overlay on the image.
- property title: str¶
- property xlabel: str¶
- property ylabel: str¶
- class magicclass.ext.pyqtgraph.widgets.LayerList(parent: magicclass.ext.pyqtgraph.widgets.HasDataItems)[source]¶
Bases:
MutableSequence
[magicclass.ext.pyqtgraph.graph_items.LayerItem
]A napari-like layer list for plot item handling.
- append(item: magicclass.ext.pyqtgraph.graph_items.LayerItem)[source]¶
S.append(value) -- append value to the end of the sequence
- insert(pos: int, item: magicclass.ext.pyqtgraph.graph_items.LayerItem)[source]¶
S.insert(index, value) -- insert value before index
- class magicclass.ext.pyqtgraph.widgets.PlotItem(viewbox: pg.ViewBox | None = None)[source]¶
Bases:
magicclass.ext.pyqtgraph.widgets.HasViewBox
A 1-D plot item that has similar API as napari Viewer.
- property legend: magicclass.ext.pyqtgraph.components.Legend¶
Legend item.
- property region: magicclass.ext.pyqtgraph.components.Region¶
Linear region item.
- property title: str¶
- property xlabel¶
Label of X-axis.
- property ylabel: str¶
Label of Y-axis.
- class magicclass.ext.pyqtgraph.widgets.QtImageCanvas(lock_contrast_limits: bool = False, **kwargs)[source]¶
Bases:
magicclass.ext.pyqtgraph.widgets.HasBackground
,magicclass.ext.pyqtgraph.widgets.ImageItem
- property background_color¶
- class magicclass.ext.pyqtgraph.widgets.QtMultiImageCanvas(nrows: int = 0, ncols: int = 0, sharex: bool = False, sharey: bool = False, **kwargs)[source]¶
Bases:
magicclass.ext.pyqtgraph.widgets._MultiPlot
[magicclass.ext.pyqtgraph.widgets.ImageItem
]A pyqtgraph-based canvas with multiple images.
- class magicclass.ext.pyqtgraph.widgets.QtMultiPlotCanvas(nrows: int = 0, ncols: int = 0, sharex: bool = False, sharey: bool = False, **kwargs)[source]¶
Bases:
magicclass.ext.pyqtgraph.widgets._MultiPlot
[magicclass.ext.pyqtgraph.widgets.PlotItem
]A pyqtgraph-based canvas with multiple plot.
- class magicclass.ext.pyqtgraph.widgets.QtPlotCanvas(**kwargs)[source]¶
Bases:
magicclass.ext.pyqtgraph.widgets.HasBackground
,magicclass.ext.pyqtgraph.widgets.PlotItem
A 1-D data viewer that have similar API as napari Viewer.
Module contents¶
PyQtGraph wrapper classes. Currently supports QtPlotCanvas
, QtMultiPlotCanvas
, Qt2YPlotCanvas
, QtImageCanvas
, QtMultiImageCanvas
and PYQTGRAPH_AVAILABLE
.
These classes offer unified API between graphical items and components, similar to those
in magicgui
and napari
.
QtPlotCanvas
can treat line plot, scatter plot, bar plot and histogram as "layers".
from magicclass.widgets import QtPlotCanvas
canvas = QtPlotCanvas()
canvas.add_curve(np.random.random(100), color="r") # like plt.plot
canvas.add_scatter(np.random.random(100), ls=":") # like plt.scatter
canvas.layers[1].visible = False # toggle visibility
canvas.enabled = False # toggle interactivity
canvas.show()
Other components such as axis labels, title and linear region have intuitive interface.
canvas.region.visible = True # show linear region
canvas.region.value # get range
canvas.xlabel = "time" # change label text
canvas.xlim = [0, 1] # change limits.
QtImageCanvas
is also designed in a similar way as QtPlotCanvas
but aims at 2D image
visualization.
from magicclass.widgets import QtImageCanvas
canvas = QtImageCanvas()
canvas.image = np.random.random((128, 128))
canvas.show()
Text overlay and scale bar are available now.
canvas.text_overlay.text = "some info"
canvas.text_overlay.color = "lime"
canvas.scale_bar.unit = "px"
canvas.scale_bar.visible = True
- class magicclass.ext.pyqtgraph.QtImageCanvas(lock_contrast_limits: bool = False, **kwargs)[source]¶
Bases:
magicclass.ext.pyqtgraph.widgets.HasBackground
,magicclass.ext.pyqtgraph.widgets.ImageItem
- property background_color¶
- class magicclass.ext.pyqtgraph.QtMultiImageCanvas(nrows: int = 0, ncols: int = 0, sharex: bool = False, sharey: bool = False, **kwargs)[source]¶
Bases:
magicclass.ext.pyqtgraph.widgets._MultiPlot
[magicclass.ext.pyqtgraph.widgets.ImageItem
]A pyqtgraph-based canvas with multiple images.
- class magicclass.ext.pyqtgraph.QtMultiPlotCanvas(nrows: int = 0, ncols: int = 0, sharex: bool = False, sharey: bool = False, **kwargs)[source]¶
Bases:
magicclass.ext.pyqtgraph.widgets._MultiPlot
[magicclass.ext.pyqtgraph.widgets.PlotItem
]A pyqtgraph-based canvas with multiple plot.
- class magicclass.ext.pyqtgraph.QtPlotCanvas(**kwargs)[source]¶
Bases:
magicclass.ext.pyqtgraph.widgets.HasBackground
,magicclass.ext.pyqtgraph.widgets.PlotItem
A 1-D data viewer that have similar API as napari Viewer.