Plotting lineage tree - #320
Open
yfukai wants to merge 7 commits into
Open
Conversation
Add plot_lineage_tree in tracksdata.functional._plot: render lineage trees with matplotlib, supporting attribute-bound node colors and sizes, time windows, and exact timestamps. Export from tracksdata.functional and add an optional `plot` extra (matplotlib). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…lineage_tree Rename color_attr/size_attr to color/size and let color, size, marker, and text each accept either a fixed value or a callable resolving a per-node value from the node's attribute row: - color: numeric attr or callable returning numbers -> cmap + colorbar; callable returning literal colors (names/hex/RGBA) -> used verbatim. - size: attr mapped to size_range, callable returning raw sizes, or constant. - marker: single glyph, or callable returning a per-node glyph (nodes are grouped by glyph, one scatter call per group, sharing one normalization). - text: attr name or callable -> per-node annotation, styled via text_kwargs. Add `attrs` to declare the node keys callables read. If a callable is given without `attrs`, warn and load all node attributes (may pull mask blobs). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WwHX5ciJfQPm9z6zmBsb27
yfukai
marked this pull request as ready for review
September 10, 2026 01:06
…ature - add `edge_color`, resolved like `color` (attribute name, callable, or literal color); numeric edge values share `cmap`/`color_norm` with the face color and are mapped manually since scatter only colormaps `c` - a `color`/`edge_color` string that is not a node attribute is taken as a literal matplotlib color (previously a ValueError) - drop `node_size`: `size` now defaults to 30.0 and accepts a float - drop `time_range`: `time_points=range(a, b + 1)` covers it Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WwHX5ciJfQPm9z6zmBsb27
- resolve requested attribute keys through a single validation path and dedupe with dict.fromkeys; typos in `size`/`text` now raise ValueError even when a callable triggers loading all attributes - fold `_resolve_color_values` into `_resolve_color_channel` - draw every marker glyph through one grouped scatter loop, inlining the former `_scatter_group` closure; scalar sizes are expanded to an array so `size` consistently overrides `scatter_kwargs["s"]` - build the successor adjacency with a polars group_by and look up node coordinates with `Series.replace_strict` - compute the orientation flag once and label the time axis via `Axis.set_label_text` - rename the shadowed `time_points` local to `shown_time_points` Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WwHX5ciJfQPm9z6zmBsb27
- `time_points` now only limits where markers are drawn; edges are drawn for every node between the first and last displayed time point, so divisions stay at their true time instead of being bridged - with `time_positions=None`, all time points in the displayed range are evenly separated (hidden ones included) and only the displayed ones are labeled - build edge segments with two polars joins on node coordinates and drop the `_bridged_edge_segments` walk - map attribute sizes with `matplotlib.colors.Normalize(clip=True)` instead of `_map_to_size_range`; `size_norm` also accepts a `Normalize` instance, mirroring `color_norm` Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WwHX5ciJfQPm9z6zmBsb27
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Plotting lineage trees of tracksdata in matplotlib. I believe this is of interest to a fraction of users!