Note
Go to the end to download the full example code.
Mixing trail styles per dataset¶
run this example as a notebook — or grab the .ipynb (also linked at the bottom of the page)
chemtrails, precog, and bullettime each accept a per-dataset list of bools instead of a single bool, so different datasets in the same animation can show different trail styles (GH #127): a low-opacity trace of the past (chemtrails), of the future (precog), or of the entire timeseries at once (bullettime – equivalent to chemtrails AND precog together).
/home/docs/checkouts/readthedocs.org/user_builds/hypertools/checkouts/latest/hypertools/plot/backend.py:1353: UserWarning: Failed to switch to any interactive backend (TkAgg, QtAgg, Qt5Agg, Qt4Agg, GTK4Agg, GTK3Agg, WXAgg). Falling back to 'Agg'.
warnings.warn(BACKEND_WARNING)
# Code source: Contextual Dynamics Laboratory
# License: MIT
import numpy as np
import hypertools as hyp
rng = np.random.default_rng(4)
n_time = 40
t = np.linspace(0, 4 * np.pi, n_time)
data_a = np.column_stack([np.cos(t), np.sin(t), t / 4])
data_b = np.column_stack([np.cos(t), -np.sin(t), t / 4]) + [3, 0, 0]
data_c = np.column_stack([np.sin(t), np.cos(t), t / 4]) + [-3, 0, 0]
# dataset 0: chemtrails (past trail) only
# dataset 1: precog (future trail) only
# dataset 2: bullettime (full trail, past + future) only
fig, ani = hyp.plot(
[data_a, data_b, data_c],
animate=True,
chemtrails=[True, False, False],
precog=[False, True, False],
bullettime=[False, False, True],
)
Total running time of the script: (0 minutes 28.266 seconds)