Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
c7ab636
test: the process watcher keeps every command line a process was seen…
jeremymanning Nov 23, 2026
40df16d
release: version 1.2.1 (changelog heading, README image links, checkl…
jeremymanning Nov 23, 2026
c11cdfc
fix: line+marker animations draw their chemtrails/precog trails; add …
jeremymanning Nov 23, 2026
ac20d5e
test+docs: GH #299 arguments (tests, docstring, animation guide, chan…
jeremymanning Nov 23, 2026
be7244a
fix: gallery layout points of GH #297 (cube clear of the canvas edge …
jeremymanning Nov 23, 2026
edf0d1a
fix: 1.2.1 review round 1 (stable label placement, hue markers on ani…
jeremymanning Nov 23, 2026
c4877f4
docs: re-execute the market and weather tutorials on the GH #297 sour…
jeremymanning Nov 23, 2026
8293312
fix: an animation's labels are placed once and hold; frames are deter…
jeremymanning Nov 23, 2026
9fed77e
fix: 1.2.1 review round 2, library (styling values decided by matplot…
jeremymanning Nov 23, 2026
2019266
fix: 1.2.1 review round 2, tests and docs (label sizes measured on on…
jeremymanning Nov 23, 2026
5f6b774
fix: 1.2.1 review round 3 (one pair of label mouse callbacks per axes…
jeremymanning Nov 23, 2026
a0ef72b
fix: 1.2.1 review round 3, label size key without the alignment (plac…
jeremymanning Nov 23, 2026
a11c09e
fix: 1.2.1 review round 4 (labels keep off legends, colorbars, titles…
jeremymanning Nov 23, 2026
d9058df
wip: checkpoint of unfinished work after a machine crash (per-frame a…
jeremymanning Nov 23, 2026
1fb6019
test: LSL discovery in the macOS test session also queries each outle…
jeremymanning Nov 23, 2026
66c33a3
docs: 1.2.1 review round 5 notes, checks made again after the crash (…
jeremymanning Nov 23, 2026
185202a
fix: 1.2.1 review round 5, second pass: an animation's labels are pla…
jeremymanning Nov 24, 2026
e588a26
fix: 1.2.1 review round 5, third pass: the animated label plan is bou…
jeremymanning Nov 24, 2026
00abdca
fix: 1.2.1 review round 5, fourth pass: matplotlib 3.11 (labels measu…
jeremymanning Nov 24, 2026
237e911
feat: labels= on streaming plots, placed causally once per update
jeremymanning Nov 24, 2026
4e6670b
docs: session notes for the 1.2.1 streaming labels (owner decision 20…
jeremymanning Nov 24, 2026
dbc451e
fix: a label or sample error mid-chunk keeps the stream's samples bef…
jeremymanning Nov 24, 2026
7a5f997
test: the stream label tests find live figures by type, not isinstanc…
jeremymanning Nov 24, 2026
54b1125
fix: a legend_colors pair key takes its dataset's line styling; a sta…
jeremymanning Nov 24, 2026
1beac7e
docs: resume notes for the 1.2.1 work (state, owner decisions, next s…
jeremymanning Nov 24, 2026
2152aee
docs: resume notes, the owner's answers of 2026-11-24 (figures approv…
jeremymanning Nov 24, 2026
5585bdd
feat: legend=, caption= and suptitle= on streaming plots
jeremymanning Nov 24, 2026
5745366
test: the stream text tests find live figures by type, not isinstance…
jeremymanning Nov 24, 2026
cf79174
release: 1.2.1 dated 2026-11-24; the market tutorial re-executed so i…
jeremymanning Nov 24, 2026
27958d0
fix: a stream refuses a wrong legend or legend_colors count before it…
jeremymanning Nov 24, 2026
3e614e9
release: record the pre-built 1.2.1 gallery
jeremymanning Nov 24, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
452 changes: 452 additions & 0 deletions CHANGELOG.md

Large diffs are not rendered by default.

23 changes: 22 additions & 1 deletion RELEASE_CHECKLIST.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,27 @@
# HyperTools 1.1 release checklist

## The 1.2.0 release: read this first
## The 1.2.1 release: read this first

`pyproject.toml` and `CHANGELOG.md` declare **1.2.1** (GH #299 and GH #297,
on top of 1.2.0, which was released on 2026-11-22: PyPI, GitHub release, Read
the Docs "stable", conda-forge). Follow the 1.2.0 notes below and read `1.2.1`
for `1.2.0` (and `v1.2.1` for `v1.2.0`) in every command, with these
differences:

- **Step 6, Read the Docs:** "stable" follows the highest version tag by
itself; confirm it instead of setting it.
- **Step 6, PyPI check:** `https://pypi.org/pypi/hypertools/<version>/json`
can keep answering a cached 404 for minutes after the upload; read
`https://pypi.org/pypi/hypertools/json` or the simple index instead.
- **Step 6, clean-environment check:** build the environment on Python 3.10
or later. On 3.9, `pip install hypertools` installs 0.8.2 without a message.
- **Step 7, conda-forge:** if the bot has not opened a bump pull request,
open one from a personal fork of the feedstock (version and sdist sha256;
compare `[project] dependencies` with the previous tag) and ask
`@conda-forge-admin` to rerender, as was done for 1.1.0 and 1.2.0.
- There are no leftovers of an earlier draft to delete.

## The 1.2.0 release (released 2026-11-22)

`pyproject.toml` and `CHANGELOG.md` declare **1.2.0** (GH #295: animated
panel grids, `caption=`, fast-start mp4; panel grids with shared colors, one
Expand Down
244 changes: 237 additions & 7 deletions docs/animation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,70 @@ reveal on **both** backends:

hyp.plot(data, '-', animate=True, order='serial', chemtrails=True)

A trail is drawn in its dataset's own format and color: a line's trail is the
faded line, a line-and-marker format's (``'-o'``, ``'o-'``, ``'.-'``,
``'--s'``) the faded line with faded markers on the observations, and a
markers-only format's its faded markers.

.. versionadded:: 1.2.1

Four arguments style the reveal:

.. code-block:: python

hyp.plot(data, '-', animate=True, chemtrails=True, linewidth=1,
trail_alpha=0.5, # trails at 0.5 x alpha (default 0.3)
tail_linewidth=3, # the recent window, drawn thicker
head_marker='o', # a marker on the last revealed point
hold=2) # hold the last frame for 2 seconds

``trail_alpha=`` is the opacity of the trails as a fraction of each dataset's
own ``alpha=`` (both backends). ``tail_linewidth=`` is the line width of the
tail, the recent window that ``tail_duration=`` sizes, while the trail keeps
``linewidth=``. ``head_marker=`` draws a marker at the reveal head only (a
matplotlib marker, ``True`` for ``'o'``, or a dict such as ``{'marker': 'D',
'size': 10, 'color': 'k'}``); its color and size follow the dataset unless
the dict sets them. The dict's keys are ``marker``, ``size``, ``color``,
``facecolor``, ``edgecolor``, ``edgewidth``, ``alpha``, ``fillstyle``,
``facecoloralt`` and ``zorder``; matplotlib's own names are taken as well
(``markersize``/``ms``, ``markerfacecolor``/``mfc``,
``markeredgecolor``/``mec``, ``markeredgewidth``/``mew``,
``markerfacecoloralt``/``mfcalt``, ``c``). ``color`` colors the whole
marker, ``facecolor`` fills it with another color (``'none'`` for a hollow
marker):

.. code-block:: python

hyp.plot(data, '-', animate=True,
head_marker={'marker': 'o', 'size': 12,
'facecolor': 'white', 'edgecolor': 'k'})

There is one head marker per dataset. When a categorical ``hue=`` or
``cluster=`` colors a dataset in several pieces, the marker is on the
dataset's current point and takes the color of the category that point is
in. On the first frame of a serial reveal, before any point is revealed, the
first dataset's marker is on its first point, as the first frame of a
parallel reveal shows every dataset's.

``hold=`` appends ``round(hold * frame_rate)`` frames
that draw the last frame again, so the pause is in a saved ``.mp4`` or
``.gif`` (a hold shorter than half a frame adds none, and a warning says
so); per-frame titles, captions and ``on_frame=`` callbacks see the last
frame's context during the hold. An ``.mp4`` stores every held frame. A
``.gif`` plays for the same time, but its writer (Pillow) stores a run of
identical frames as one frame with a longer duration, so it has fewer stored
frames than ``n_frames``. ``tail_linewidth=``, ``head_marker=`` and ``hold=``
are matplotlib only: an animated plot under ``backend='plotly'`` raises
``NotImplementedError``. On a static plot (either backend)
``tail_linewidth=``, ``head_marker=`` and ``trail_alpha=`` are ignored with a
warning, and ``hold=`` raises ``ValueError``. ``tail_linewidth=`` also warns
when no dataset is drawn with a line (a markers-only format). All four may
also be given inside the ``animate={...}`` dict.

With a continuous ``hue=`` the tail and the trail are colored observation by
observation, whatever the format: a line (``'-'``), markers (``'o'``), or
both (``'-o'``, the colored line with a colored marker on each observation).

Fading earlier datasets
------------------------

Expand Down Expand Up @@ -122,12 +186,144 @@ reserves room for every line above an animated 3-D plot, not just one.
On the matplotlib backend the room above an animated plot is made for the
tallest title the animation shows: a fixed title's own lines, the tallest
entry of a per-segment list, and, for a callable or ``'{index...}'`` title,
the tallest of the first, middle and last frames' titles, so a title that
grows lines as the animation runs has its room from the start (a frame in
between that needs more lines than all three runs above it). The figure is
the tallest of every frame's titles, so a title that grows lines on any
frame has its room from the start (the callable is called once per frame
for this before the animation is returned). The figure is
made taller by what the title needs, in 2-D and in 3-D, and nothing already
drawn moves or shrinks.

Labels on the points
--------------------

``labels=`` works in an animation as it does in a static plot, and every
frame's labels are placed for that frame (matplotlib backend):

.. code-block:: python

hyp.plot(data, 'o', animate='spin', labels=names,
legend=['group'], title='Subjects', caption='One point each')

* Each label is attached to its point where the frame shows it. As a 3-D
plot turns, the labels turn with their points.
* On every frame the labels are kept off each other, off the legend, the
colorbar, the titles, the suptitle and the caption, off the cube's own
axis labels, out of the next panel of a ``panels=`` grid, and inside the
canvas.
* The labels of points a frame does not show (not revealed yet, outside
the sliding window) are hidden.
* Labels do not hop about. Every label is given a plan for the whole
animation before a frame is drawn: it stays at one place by its point
for as long as that place is clear (the nearest such place; further
out, up to 130 points, where the plot is crowded). When another label
is about to arrive it glides to its next place over about a third of a
second, before the other gets there, and then stays for a second, so
it never goes out and straight back. A spin of whole turns is planned
round the loop, so its last frame leads into its first.
* With a dozen labels no two overlap on any frame. With more than the
canvas has room for (thirty on a default-size cube that turns once in
four seconds) a few still do for a moment: under one pair a frame,
where placing each frame on its own leaves five or six and makes the
labels hop. A larger figure, a slower turn or fewer labels clears
them.
* A frame is the same picture however it is reached: played in order,
shown out of order with ``draw_frame``, or saved to a file.

The legend, the titles, the suptitle, the caption, the colorbar and the
size of the cube are laid out once, for the widest view of the whole
animation (the cube with its axis labels, at every frame's camera angle),
and do not move or change size from one frame to the next. The axis labels
of a 3-D plot turn with the cube and stay inside the canvas at every angle.

Working the places out costs time when the plot is made, not when it
plays: about half a second for 20 labels over 60 frames, 1.5 seconds for
60 and 2.5 seconds for 200. The more labels, the fewer times each label's plan
is revised: above 80 labels a label that still lies on another is not
planned a second time, and above 300 the labels stay at their usual
places. An animation with more than 3600 labels x frames is planned at
evenly spaced frames (3600 over the number of labels, at least 40), and
its labels move evenly between them, so a long animation takes no longer
to plan than a short one and its plan is no larger. The plan is made
again when the figure is resized, a label's text or font is changed, or a
legend or text is added to the figure. A pickled or copied figure has no
animation to follow: its labels stay where the frame it was taken at had
them. On the plotly backend the labels are annotations
attached to their points: they follow the points as the scene turns, at
one fixed offset, and are shown on every frame.

Labels on a stream
~~~~~~~~~~~~~~~~~~

A streaming plot (an iterator, a generator or a Hugging Face
``IterableDataset`` passed as the data, see the
:doc:`streaming data tutorial <tutorials/streaming_data>`) takes
``labels=`` too (new in 1.2.1, matplotlib). The number of samples is not
known in advance, so the labels are not one list with an entry per
observation. Pass either a callable or an iterable:

.. code-block:: python

# a callable: called once per sample with its position in the stream
# and the sample as the stream yielded it
hyp.plot(feed(), stream_init=500, stream_window=750,
labels=lambda i, sample: f't = {i}' if i % 100 == 0 else None)

# an iterable (a list, or an iterator or generator, which may be
# endless), consumed in step with the samples
hyp.plot(feed(), stream_init=500, labels=['start', None, None, 'third'])

* ``None`` (or NaN, or a blank string) draws no label. A list that is
shorter than the stream labels the first samples only.
* With dict samples, such as the rows of a Hugging Face stream, the
callable can read a text field that the numeric conversion ignores:
``labels=lambda i, row: row['title']``.
* Every label is attached to its sample's drawn position on every frame.
With ``stream_window=`` a label is removed when its sample leaves the
window. The labels of all consumed samples are kept in
``fig.stream_info['labels']``.
* The samples to come are unknown, so the labels cannot be planned for the
whole animation as above. They are placed once per update by the same
rule (off each other, off the title, legends and figure texts, inside the
canvas), starting from where the update before left them. A label keeps
its place while that place is clear. A new label takes a free place, and
the labels already shown stay where they are. A label that has to move
(the figure was resized or turned, or room came free for a label that had
none) glides to the nearest free place over about 0.4 seconds of frames,
rests there, and does not go back to the place it left for six glides
unless nothing else is free.
* The title, the axes and the display box are laid out once, from the
first ``stream_init`` samples, and do not move while the stream runs.
* The same stream in the same chunks saves the same frames. The placement
depends on the updates so far, never on a clock or on how often the
figure is drawn.
* Placing the labels of an update takes about 0.5 ms with 10 visible
labels, 1 ms with 50 and 3 ms with 200. At most 300 visible labels are
kept off each other (the oldest); the others hang at the usual place and
a warning says so once. Without ``stream_window=`` every label stays on
the figure, so memory grows with the number of labeled samples.

A stream also takes ``legend=`` (with ``legend_kwargs=`` and
``legend_colors=``), ``caption=`` (with ``caption_kwargs=``) and
``suptitle=`` (with ``suptitle_kwargs=``), new in 1.2.1:

.. code-block:: python

hyp.plot(feed(), '-o', stream_init=500, legend=['sensor A'],
suptitle='Live recording', caption='Projected with PCA.')

They are laid out once, when the first ``stream_init`` samples are drawn,
and stay where they are for the whole stream. The display box is frozen
from those samples, so the room made for the legend holds on every later
frame, and the legend key is drawn in the style of the streamed line. The
labels of a stream keep off all three. A stream's caption is one fixed
string: a callable (a per-frame caption) raises ``TypeError``, because the
number of frames of a stream is not known. With ``ax=``, ``caption=`` and
``suptitle=`` raise as they do on any plot drawn into a caller's axes, and
the legend is drawn in that axes.

The arguments a stream does not implement (``head_marker=``,
``tail_linewidth=``, ``trail_alpha=`` among them) are still ignored with a
warning that names them.

Per-dataset styling
-------------------

Expand Down Expand Up @@ -205,7 +401,14 @@ The context carries the frame index and total, the resolved ``style`` and
``segment_kind``. All of those are the same on either backend.

What you *do* with the context is usually backend-specific, because
``ctx.figure``, ``ctx.axes`` and ``ctx.artists`` are backend-native. The
``ctx.figure``, ``ctx.axes`` and ``ctx.artists`` are backend-native. On
matplotlib ``ctx.artists`` holds one artist per dataset's reveal head, then
the trails. Two things are drawn by a second artist that is not in the list
and follows the listed one: the markers of a line-and-marker format
(``'-o'``) under a continuous ``hue=``, which are hidden when the listed
line is hidden and take its ``alpha``; and a ``head_marker=``, which is
hidden when its dataset's head artist is hidden. So
``ctx.artists[0].set_visible(False)`` hides the whole trace. The
matplotlib form:

.. code-block:: python
Expand Down Expand Up @@ -842,9 +1045,9 @@ has no blank room there (an animated 3-D plot fills its canvas) the figure
is made taller by the caption's height, so the caption never overlaps a
panel, a legend or a colorbar and never leaves the canvas. A caption wider
than the figure is wrapped to the figure's width, on every frame. Room is
made for the tallest of the first, middle and last frames' wrapped captions,
so a caption that grows as the animation runs has its room from the start
(a frame in between that needs more lines than all three runs below it). An
made for the tallest of every frame's wrapped captions, so a caption that
grows on any frame has its room from the start (a callable caption is
called once per frame for this before the animation is returned). An
empty caption draws nothing and adds no room. On a static plot the caption
is drawn once, a pattern or callable being resolved for the finished figure.

Expand All @@ -857,6 +1060,33 @@ the panel that draws it (the first panel under a list-valued ``reduce=``).
per-frame ``title=`` works on both backends) and ``ValueError`` with a
caller-supplied ``ax=``.

.. versionadded:: 1.2.1

``caption_kwargs=`` styles and places the caption: ``size``, ``color``,
``weight``, ``style``, ``family``, ``alpha``, ``linespacing``, ``position``
(``'bottom'``, the default, or ``'top'``) and ``loc`` (``'center'``,
``'left'`` or ``'right'``). The style is applied before the caption is
wrapped and its room measured, and a per-frame caption is measured on every
frame, so a caption of any size is never clipped. matplotlib decides what
each key accepts (a size may be a number, a numeric string or a size name,
and a key set to ``None`` keeps its default); a value it refuses, or a size
that is not positive and finite, raises ``ValueError`` naming the argument
and the key.

``suptitle=`` is one fixed title for the whole figure, above everything it
holds. It is the figure-level title of a ``panels=`` grid, static or
animated, where ``title=`` names the panels; ``suptitle_kwargs=`` styles it
with the same keys (except ``position``). Its room is measured like the
caption's, so it clears the panel titles, the shared legend and colorbar,
and a caption placed at the top:

.. code-block:: python

hyp.plot([a, b, c, d], '-', panels=(2, 2), animate=True,
title=['a', 'b', 'c', 'd'], suptitle='Four walks, one clock',
caption=lambda ctx: f'frame {ctx.frame + 1} of {ctx.n_frames}',
caption_kwargs={'size': 13, 'color': 'gray', 'loc': 'right'})

Companion panels
-----------------

Expand Down
6 changes: 3 additions & 3 deletions docs/prebuilt_gallery.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"commit": "afb1e0d907b65adac1d63bf7357f3a73d8653008",
"source_commit": "9e6ababc5c70763a37c0a45290b668b0a4e554df",
"version": "1.2.0"
"commit": "2b70b5737f1d4601f1442dbfc9894a0a1c9e7a0c",
"source_commit": "27958d07057199d785cd917c1c0b08247a793aaa",
"version": "1.2.1"
}
Loading
Loading