anyplotlib.Plot2D#
- class anyplotlib.Plot2D(data, x_axis=None, y_axis=None, units='px', cmap=None, vmin=None, vmax=None, origin='upper')[source]#
Bases:
object2-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
- on_key(key_or_fn=None)[source]#
Register a key-press handler for this panel.
Two call forms are supported:
@plot.on_key('q') # fires only when 'q' is pressed def handler(event): ... @plot.on_key # fires for every registered key def handler(event): ...
The event carries:
key,mouse_x,mouse_y,phys_x, andlast_widget_id.Note
Registered keys take priority over the built-in r (reset view) shortcut.
- Return type:
- disconnect(cid)[source]#
Remove the callback registered under integer cid.
- Parameters:
cid (int)
- Return type:
None
- 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)[source]#
Add circle markers at (x, y) positions in data coordinates.
- 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)[source]#
Add point markers at (x, y) positions in data coordinates.
- Return type:
- add_hlines(y_values, name=None, *, color='#ff0000', linewidths=1.5, hover_edgecolors=None, labels=None, label=None)[source]#
Add static horizontal lines at the given y positions.
- Return type:
- add_vlines(x_values, name=None, *, color='#ff0000', linewidths=1.5, hover_edgecolors=None, labels=None, label=None)[source]#
Add static vertical lines at the given x positions.
- Return type:
- add_arrows(offsets, U, V, name=None, *, edgecolors='#ff0000', linewidths=1.5, hover_edgecolors=None, labels=None, label=None)[source]#
- 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)[source]#
- Return type:
- add_lines(segments, name=None, *, edgecolors='#ff0000', linewidths=1.5, hover_edgecolors=None, labels=None, label=None)[source]#
- 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)[source]#
- 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)[source]#
- 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)[source]#
- Return type:
- add_texts(offsets, texts, name=None, *, color='#ff0000', fontsize=12, hover_edgecolors=None, labels=None, label=None)[source]#
- Return type: