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
- base_item: type[pg.PlotCurveItem | pg.ScatterPlotItem]¶
- property color: numpy.ndarray¶
- property linestyle¶
- property linewidth¶
- property ls¶
- property lw¶
- property ndata: int¶
- property visible¶
- property xdata: numpy.ndarray¶
- property ydata: numpy.ndarray¶
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.
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: list[magicclass.widgets.qtgraph.graph_items.PlotDataItem]¶
- class magicclass.widgets.qtgraph.qt_graph.QtImageCanvas(image: Optional[numpy.ndarray] = None, cmap=None, contrast_limits: Optional[tuple[float, float]] = None, **kwargs)[source]¶
Bases:
magicgui.widgets._bases.widget.Widget
,magicgui.widgets._bases.mixins._OrientationMixin
,MutableSequence
[magicgui.widgets._bases.widget.Widget
]- property cmap¶
Color map
- property contrast_limits: tuple[float, float]¶
Contrast limits of image
- property image: numpy.ndarray¶
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:
magicgui.widgets._bases.widget.Widget
,magicgui.widgets._bases.mixins._OrientationMixin
,MutableSequence
[magicgui.widgets._bases.widget.Widget
]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.
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()