aliabd HF staff commited on
Commit
8eda64c
·
1 Parent(s): def546d

Upload with huggingface_hub

Browse files
Files changed (3) hide show
  1. README.md +5 -6
  2. requirements.txt +1 -0
  3. run.py +31 -0
README.md CHANGED
@@ -1,12 +1,11 @@
 
1
  ---
2
- title: Sine Curve
3
- emoji: 🚀
4
- colorFrom: blue
5
  colorTo: indigo
6
  sdk: gradio
7
  sdk_version: 3.8.1
8
- app_file: app.py
9
  pinned: false
10
  ---
11
-
12
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
+
2
  ---
3
+ title: sine_curve
4
+ emoji: 🔥
5
+ colorFrom: indigo
6
  colorTo: indigo
7
  sdk: gradio
8
  sdk_version: 3.8.1
9
+ app_file: run.py
10
  pinned: false
11
  ---
 
 
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ plotly
run.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import math
2
+ import gradio as gr
3
+ import plotly.express as px
4
+ import numpy as np
5
+
6
+
7
+ plot_end = 2 * math.pi
8
+
9
+
10
+ def get_plot(period=1):
11
+ global plot_end
12
+ x = np.arange(plot_end - 2 * math.pi, plot_end, 0.02)
13
+ y = np.sin(2*math.pi*period * x)
14
+ fig = px.line(x=x, y=y)
15
+ plot_end += 2 * math.pi
16
+ return fig
17
+
18
+
19
+ with gr.Blocks() as demo:
20
+ with gr.Row():
21
+ with gr.Column():
22
+ gr.Markdown("Change the value of the slider to automatically update the plot")
23
+ period = gr.Slider(label="Period of plot", value=1, minimum=0, maximum=10, step=1)
24
+ plot = gr.Plot(label="Plot (updates every half second)")
25
+
26
+ dep = demo.load(get_plot, None, plot, every=1)
27
+ period.change(get_plot, period, plot, every=1, cancels=[dep])
28
+
29
+
30
+ if __name__ == "__main__":
31
+ demo.queue().launch()