Spaces:
Sleeping
Sleeping
Daniel1213
commited on
Commit
•
ce38c89
1
Parent(s):
2717de4
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from bokeh.plotting import figure
|
3 |
+
|
4 |
+
|
5 |
+
def get_plot(plot_type):
|
6 |
+
plot = figure()
|
7 |
+
x=[1,2,3,4]
|
8 |
+
y=[2,4,5,6]
|
9 |
+
if (plot_type=="scatter"):
|
10 |
+
plot.scatter(x=x, y=y)
|
11 |
+
if (plot_type=="line"):
|
12 |
+
plot.line(x=x, y=y)
|
13 |
+
if (plot_type=="bar"):
|
14 |
+
plot.vbar(x=x, top=y , bottom=0)
|
15 |
+
return plot
|
16 |
+
|
17 |
+
|
18 |
+
with gr.Blocks() as demo:
|
19 |
+
with gr.Row():
|
20 |
+
plot_type = gr.Radio(value="scatter", choices=["scatter", "line", "bar"])
|
21 |
+
plot = gr.Plot()
|
22 |
+
plot_type.change(get_plot, inputs=[plot_type], outputs=[plot])
|
23 |
+
demo.load(get_plot, inputs=[plot_type], outputs=[plot])
|
24 |
+
|
25 |
+
|
26 |
+
demo.launch()
|