Congrats to @ahuang11 who just released ahlive
.
Ahlive is an open-source Python package that makes animating data simple, clean, and enjoyable!
Check it out ahlive.readthedocs.io
panel-feels-alive
Run the example below via panel serve name_of_file.py
.
"""Ahlive is an open-source Python package that makes animating data simple, clean, and
enjoyable!
[ahlive.readthedocs.io](https://ahlive.readthedocs.io/en/latest/)
`pip install ahlive`
"""
import ahlive as ah
import panel as pn
import pathlib
pn.sizing_mode="stretch_width"
NOAA_CO2_PATH = pathlib.Path(__file__).parent/"nooa_co2.gif"
def render_nooa_co2():
if NOAA_CO2_PATH.exists():
return
df = ah.open_dataset(label="annual_co2")
ah_df = ah.DataFrame(
df,
xs="year",
ys="co2_ppm",
ylim1s='explore_0.05',
ylabel="CO2 [ppm]",
state_labels="year",
inline_labels="co2_ppm",
title="Annual Mean CO2 Concentration",
save=str(NOAA_CO2_PATH),
show=False
)
ah_df = ah_df.reference(x0s='x', label='')
ah_df = ah_df.remark(xs=1760, durations=1, remarks="Industrial Revolution")
ah_df = ah_df.config('inline', suffix=' ppm')
ah_df.render()
progress = pn.widgets.Progress(active=True, bar_color="success")
progress_text = pn.widgets.StaticText(value="Rendering")
progress_row = pn.Row(progress, progress_text, sizing_mode="fixed")
noaa_co2_pane = pn.pane.GIF()
def render():
progress.active = True
progress_text.value = "Rendering NOOA CO2"
render_nooa_co2()
noaa_co2_pane.object = str(NOAA_CO2_PATH)
progress_row.clear()
template = pn.template.VanillaTemplate(title="Panel feels Ahlive")
template.main.append(pn.pane.Markdown(__doc__, sizing_mode="stretch_width"))
template.main.append(progress_row)
template.main.append(noaa_co2_pane)
pn.state.onload(render)
template.servable()