Py.Cafe

jc797tc98yrdoj86d/

remarkable-troll

Interactive Sine Wave Explorer

DocsPricing
  • app.py
  • requirements.txt
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
"""# Interactive sine wave


This example shows how to have two slider control a visualization.

"""

import numpy as np
import plotly.express as px

import solara

x = np.linspace(0, 2, 100)

title = "Interactive sine wave"
print("\n\n")
freq = solara.reactive(2.0)
phase = solara.reactive(0.1)


@solara.component
def Page():
    print("\n\n\n")
    y = np.sin(x * freq.value + phase.value)
    fig = px.line(x=x, y=y)
    solara.FigurePlotly(fig)
    with solara.Columns([1, 1, 1]):
        #solara.Text("I am as small as possible")
        #solara.Select("I stretch", values=["a", "b", "c"], value="a")
        #solara.Select("I stretch twice the amount", values=["a", "b", "c"], value="a")
        solara.FloatSlider("Frequency", value=freq, min=0, max=10)
        solara.FloatSlider("Phase", value=phase, min=0, max=np.pi, step=0.1)