Markers#
markers.py#
Marker registry for Plot1D and Plot2D panels inside a Figure.
The public API mirrors matplotlib’s collection kwargs:
- plot.add_circles(offsets, name=”group1”,
facecolors=”#ff0000”, edgecolors=”#ffffff”, radius=5, labels=[…])
plot.markers[“circles”][“group1”].set(offsets=new_offsets, radius=3)
Design#
MarkerGroup– a single named collection of markers (one type).MarkerTypeDict– dict-like for one type; mutations propagate to the plot.MarkerRegistry– top-level two-level dict: registry[type][name].
All state is stored as plain Python dicts; no traitlets here. The _push
callback is supplied by the parent plot and is responsible for serialising
the full registry into the panel’s JSON trait on the Figure widget.
Wire-format translation#
The JS renderer uses the same internal field names as the standalone viewers
(color, fill_color, fill_alpha, sizes, etc.). MarkerGroup
stores matplotlib-style names and to_wire() translates before JSON
serialisation.
- class anyplotlib.markers.MarkerGroup(marker_type, name, kwargs, push_fn)[source]#
Bases:
objectA named collection of markers of one type on one plot.
- Parameters:
marker_type (str) – One of the supported marker types (
'circles','lines', …).name (str) – User-facing name (key in the parent
MarkerTypeDict).kwargs (dict) – Initial matplotlib-style kwargs for this group.
push_fn (callable) – Zero-arg callback that serialises the full registry and pushes it to the parent figure trait.
- class anyplotlib.markers.MarkerTypeDict(marker_type, push_fn)[source]#
Bases:
objectDict-like container for all named groups of one marker type.
Any modification (
__setitem__,__delitem__) automatically triggers the_push_fncallback so the plot re-renders.- Parameters:
marker_type (str)
- class anyplotlib.markers.MarkerRegistry(push_fn, allowed=None)[source]#
Bases:
objectTop-level two-level marker registry for a plot.
Usage:
plot.markers["circles"]["group1"].set(offsets=new_offsets)
plot.markersis aMarkerRegistry. Indexing by type returns aMarkerTypeDict(auto-created on first access).- Parameters:
allowed (frozenset | None)
- add(marker_type, name=None, **kwargs)[source]#
Add a marker group, returning the
MarkerGroup.- Parameters:
- Return type: