pandas_panel.py 960 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. import panel as pn
  2. import numpy as np
  3. import holoviews as hv
  4. pn.extension(sizing_mode='stretch_width')
  5. bootstrap = pn.template.BootstrapTemplate(title='Bootstrap Template')
  6. xs = np.linspace(0, np.pi)
  7. freq = pn.widgets.FloatSlider(name="Frequency", start=0, end=10, value=2)
  8. phase = pn.widgets.FloatSlider(name="Phase", start=0, end=np.pi)
  9. @pn.depends(freq=freq, phase=phase)
  10. def sine(freq, phase):
  11. return hv.Curve((xs, np.sin(xs * freq + phase))).opts(
  12. responsive=True, min_height=400)
  13. @pn.depends(freq=freq, phase=phase)
  14. def cosine(freq, phase):
  15. return hv.Curve((xs, np.cos(xs * freq + phase))).opts(
  16. responsive=True, min_height=400)
  17. def main():
  18. bootstrap.sidebar.append(freq)
  19. bootstrap.sidebar.append(phase)
  20. bootstrap.main.append(
  21. pn.Row(
  22. pn.Card(hv.DynamicMap(sine), title='Sine'),
  23. pn.Card(hv.DynamicMap(cosine), title='Cosine')
  24. )
  25. )
  26. bootstrap.servable()
  27. main()