Spaces:
Runtime error
Runtime error
Daniel1213
commited on
Commit
•
23a4e82
1
Parent(s):
56b3e5d
Update app.py
Browse files
app.py
CHANGED
@@ -4,28 +4,32 @@ from bokeh.plotting import figure
|
|
4 |
|
5 |
|
6 |
def get_plot(plot_type):
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
)
|
11 |
-
|
|
|
|
|
|
|
|
|
12 |
return plot
|
13 |
|
14 |
|
15 |
css = """
|
16 |
#plotly_Graph div:nth-of-type(2){
|
17 |
-
HEIGHT:
|
18 |
}
|
19 |
@media(min-width:1200px){
|
20 |
#plotly_Graph div:nth-of-type(2){
|
21 |
-
HEIGHT:
|
22 |
}
|
23 |
}
|
24 |
"""
|
25 |
|
26 |
with gr.Blocks(css=css) as demo:
|
27 |
with gr.Row():
|
28 |
-
plot_type = gr.Radio(value="scatter", choices=["scatter", "
|
29 |
plot = gr.Plot(elem_id="plotly_Graph")
|
30 |
plot_type.change(get_plot, inputs=[plot_type], outputs=[plot])
|
31 |
demo.load(get_plot, inputs=[plot_type], outputs=[plot])
|
|
|
4 |
|
5 |
|
6 |
def get_plot(plot_type):
|
7 |
+
plot = figure(sizing_mode='stretch_both')
|
8 |
+
x=[1,2,3,4]
|
9 |
+
y=[2,4,5,6]
|
10 |
+
if (plot_type=="scatter"):
|
11 |
+
plot.scatter(x=x, y=y)
|
12 |
+
if (plot_type=="line"):
|
13 |
+
plot.line(x=x, y=y)
|
14 |
+
if (plot_type=="bar"):
|
15 |
+
plot.vbar(x=x, top=y , bottom=0)
|
16 |
return plot
|
17 |
|
18 |
|
19 |
css = """
|
20 |
#plotly_Graph div:nth-of-type(2){
|
21 |
+
HEIGHT:200px;
|
22 |
}
|
23 |
@media(min-width:1200px){
|
24 |
#plotly_Graph div:nth-of-type(2){
|
25 |
+
HEIGHT:400px;
|
26 |
}
|
27 |
}
|
28 |
"""
|
29 |
|
30 |
with gr.Blocks(css=css) as demo:
|
31 |
with gr.Row():
|
32 |
+
plot_type = gr.Radio(value="scatter", choices=["scatter", "line", "bar"])
|
33 |
plot = gr.Plot(elem_id="plotly_Graph")
|
34 |
plot_type.change(get_plot, inputs=[plot_type], outputs=[plot])
|
35 |
demo.load(get_plot, inputs=[plot_type], outputs=[plot])
|