anyplotlib.Plot2D#
- class anyplotlib.Plot2D(data, x_axis=None, y_axis=None, units='px', cmap=None, vmin=None, vmax=None, origin='upper')[source]#
Bases:
_BasePlot,_PanelMixin,_MarkerMixin2-D image plot panel.
Not an anywidget. Holds state in
_statedict; every mutation calls_push()which writes to the parent Figure’s panel trait.- The marker API follows matplotlib conventions:
plot.add_circles(offsets, name=”g1”, facecolors=”#f00”, radius=5) plot.markers[“circles”][“g1”].set(radius=8)
- Parameters:
- property data: ndarray#
The image data in the original user coordinate system (read-only).
Returns a float64 copy with
writeable=False. To replace the data callset_data().
- set_data(data, x_axis=None, y_axis=None, units=None)[source]#
Replace the image data.
The
originsupplied at construction is automatically re-applied so the new data is displayed with the same orientation.
- set_overlay_mask(mask, color='#ff4444', alpha=0.4)[source]#
Set (or clear) a transparent boolean mask drawn over the image.
The mask is composited client-side in the browser at alpha opacity using color for all
Truepixels. Call withmask=Noneto remove any existing overlay.- Parameters:
mask (ndarray of shape (H, W), bool or uint8, or None) – Boolean array aligned to the image data.
True/ non-zero pixels are filled with color at transparency alpha. PassNoneto clear the overlay.color (str, optional) – CSS hex colour for the overlay, e.g.
"#ff4444". Default red. Must be in#RRGGBBformat.alpha (float, optional) – Opacity in [0, 1]. Default 0.4 (40 % opaque).
- Return type:
None
- set_ylabel(label, fontsize=None)[source]#
Set the y-axis label. Same semantics as
set_xlabel().
- set_colorbar_label(label, fontsize=None)[source]#
Set the colorbar label (mini-TeX allowed; default size 10 px).
- add_widget(kind, color='#00e5ff', **kwargs)[source]#
Add an overlay widget by kind name.
Dispatches to the dedicated
add_<kind>_widgetmethod. Supported kinds:"circle","rectangle","annular","polygon","crosshair","label".
- add_circle_widget(cx=None, cy=None, r=None, color='#00e5ff')[source]#
Add a draggable circle overlay.
- Parameters:
- Return type:
- add_rectangle_widget(x=None, y=None, w=None, h=None, color='#00e5ff')[source]#
Add a draggable rectangle overlay.
- add_annular_widget(cx=None, cy=None, r_outer=None, r_inner=None, color='#00e5ff')[source]#
Add a draggable annular (ring) overlay.
- add_polygon_widget(vertices=None, color='#00e5ff')[source]#
Add a draggable polygon overlay.
- Parameters:
color (str)
- Return type:
- add_crosshair_widget(cx=None, cy=None, color='#00e5ff')[source]#
Add a draggable crosshair overlay.
- Parameters:
- Return type:
- add_label_widget(x=None, y=None, text='Label', fontsize=14, color='#00e5ff')[source]#
Add a draggable text label overlay.
- set_view(x0=None, x1=None, y0=None, y1=None)[source]#
Set the viewport to a data-space rectangle.
- Parameters:
x0 (float, optional) – Horizontal data-space range to show. If omitted the full x-extent is used for zoom calculation.
x1 (float, optional) – Horizontal data-space range to show. If omitted the full x-extent is used for zoom calculation.
y0 (float, optional) – Vertical data-space range to show. If omitted the full y-extent is used for zoom calculation.
y1 (float, optional) – Vertical data-space range to show. If omitted the full y-extent is used for zoom calculation.
center_x (Translates the requested rectangle into the zoom /)
renderer. (/ center_y state values used by the 2-D JS)
- Return type:
None
- add_circles(offsets, name=None, *, radius=5, facecolors=None, edgecolors='#ff0000', linewidths=1.5, alpha=0.3, hover_edgecolors=None, hover_facecolors=None, labels=None, label=None, transform='data')[source]#
Add circle markers at (x, y) positions in data coordinates.
- Parameters:
transform (str)
- Return type:
- add_points(offsets, name=None, *, sizes=5, color='#ff0000', facecolors=None, linewidths=1.5, alpha=0.3, hover_edgecolors=None, hover_facecolors=None, labels=None, label=None, transform='data')[source]#
Add point markers at (x, y) positions in data coordinates.
- Parameters:
transform (str)
- Return type:
- add_hlines(y_values, name=None, *, color='#ff0000', linewidths=1.5, hover_edgecolors=None, labels=None, label=None, transform='data')[source]#
Add static horizontal lines at the given y positions.
- Parameters:
transform (str)
- Return type:
- add_vlines(x_values, name=None, *, color='#ff0000', linewidths=1.5, hover_edgecolors=None, labels=None, label=None, transform='data')[source]#
Add static vertical lines at the given x positions.
- Parameters:
transform (str)
- Return type:
- add_arrows(offsets, U, V, name=None, *, edgecolors='#ff0000', linewidths=1.5, hover_edgecolors=None, labels=None, label=None, transform='data')[source]#
- Parameters:
transform (str)
- Return type:
- add_ellipses(offsets, widths, heights, name=None, *, angles=0, facecolors=None, edgecolors='#ff0000', linewidths=1.5, alpha=0.3, hover_edgecolors=None, hover_facecolors=None, labels=None, label=None, transform='data')[source]#
- Parameters:
transform (str)
- Return type:
- add_lines(segments, name=None, *, edgecolors='#ff0000', linewidths=1.5, hover_edgecolors=None, labels=None, label=None, transform='data')[source]#
- Parameters:
transform (str)
- Return type:
- add_rectangles(offsets, widths, heights, name=None, *, angles=0, facecolors=None, edgecolors='#ff0000', linewidths=1.5, alpha=0.3, hover_edgecolors=None, hover_facecolors=None, labels=None, label=None, transform='data')[source]#
- Parameters:
transform (str)
- Return type:
- add_squares(offsets, widths, name=None, *, angles=0, facecolors=None, edgecolors='#ff0000', linewidths=1.5, alpha=0.3, hover_edgecolors=None, hover_facecolors=None, labels=None, label=None, transform='data')[source]#
- Parameters:
transform (str)
- Return type:
- add_polygons(vertices_list, name=None, *, facecolors=None, edgecolors='#ff0000', linewidths=1.5, alpha=0.3, hover_edgecolors=None, hover_facecolors=None, labels=None, label=None, transform='data')[source]#
- Parameters:
transform (str)
- Return type: