Spaces:
Running
Running
Upload folder using huggingface_hub
Browse files- bar_plot_demo.py +9 -9
- line_plot_demo.py +5 -16
- requirements.txt +2 -2
- scatter_plot_demo.py +7 -8
bar_plot_demo.py
CHANGED
|
@@ -98,14 +98,14 @@ def bar_plot_fn(display):
|
|
| 98 |
|
| 99 |
|
| 100 |
with gr.Blocks() as bar_plot:
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
)
|
| 108 |
-
with gr.Column():
|
| 109 |
-
plot = gr.BarPlot(show_label=False, show_actions_button=True)
|
| 110 |
display.change(bar_plot_fn, inputs=display, outputs=plot)
|
| 111 |
bar_plot.load(fn=bar_plot_fn, inputs=display, outputs=plot)
|
|
|
|
|
|
|
|
|
|
|
|
| 98 |
|
| 99 |
|
| 100 |
with gr.Blocks() as bar_plot:
|
| 101 |
+
display = gr.Dropdown(
|
| 102 |
+
choices=["simple", "stacked", "grouped", "simple-horizontal", "stacked-horizontal", "grouped-horizontal"],
|
| 103 |
+
value="simple",
|
| 104 |
+
label="Type of Bar Plot"
|
| 105 |
+
)
|
| 106 |
+
plot = gr.BarPlot(show_label=False)
|
|
|
|
|
|
|
|
|
|
| 107 |
display.change(bar_plot_fn, inputs=display, outputs=plot)
|
| 108 |
bar_plot.load(fn=bar_plot_fn, inputs=display, outputs=plot)
|
| 109 |
+
|
| 110 |
+
if __name__ == "__main__":
|
| 111 |
+
bar_plot.launch()
|
line_plot_demo.py
CHANGED
|
@@ -24,8 +24,6 @@ def line_plot_fn(dataset):
|
|
| 24 |
overlay_point=False,
|
| 25 |
title="Stock Prices",
|
| 26 |
stroke_dash_legend_title=None,
|
| 27 |
-
height=300,
|
| 28 |
-
width=500
|
| 29 |
)
|
| 30 |
elif dataset == "climate":
|
| 31 |
return gr.LinePlot(
|
|
@@ -40,8 +38,6 @@ def line_plot_fn(dataset):
|
|
| 40 |
overlay_point=False,
|
| 41 |
title="Climate",
|
| 42 |
stroke_dash_legend_title=None,
|
| 43 |
-
height=300,
|
| 44 |
-
width=500
|
| 45 |
)
|
| 46 |
elif dataset == "seattle_weather":
|
| 47 |
return gr.LinePlot(
|
|
@@ -56,8 +52,6 @@ def line_plot_fn(dataset):
|
|
| 56 |
overlay_point=True,
|
| 57 |
title="Seattle Weather",
|
| 58 |
stroke_dash_legend_title=None,
|
| 59 |
-
height=300,
|
| 60 |
-
width=500
|
| 61 |
)
|
| 62 |
elif dataset == "gapminder":
|
| 63 |
return gr.LinePlot(
|
|
@@ -72,20 +66,15 @@ def line_plot_fn(dataset):
|
|
| 72 |
overlay_point=False,
|
| 73 |
title="Life expectancy for countries",
|
| 74 |
stroke_dash_legend_title="Country Cluster",
|
| 75 |
-
height=300,
|
| 76 |
-
width=500
|
| 77 |
)
|
| 78 |
|
| 79 |
|
| 80 |
with gr.Blocks() as line_plot:
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
)
|
| 87 |
-
with gr.Column():
|
| 88 |
-
plot = gr.LinePlot()
|
| 89 |
dataset.change(line_plot_fn, inputs=dataset, outputs=plot)
|
| 90 |
line_plot.load(fn=line_plot_fn, inputs=dataset, outputs=plot)
|
| 91 |
|
|
|
|
| 24 |
overlay_point=False,
|
| 25 |
title="Stock Prices",
|
| 26 |
stroke_dash_legend_title=None,
|
|
|
|
|
|
|
| 27 |
)
|
| 28 |
elif dataset == "climate":
|
| 29 |
return gr.LinePlot(
|
|
|
|
| 38 |
overlay_point=False,
|
| 39 |
title="Climate",
|
| 40 |
stroke_dash_legend_title=None,
|
|
|
|
|
|
|
| 41 |
)
|
| 42 |
elif dataset == "seattle_weather":
|
| 43 |
return gr.LinePlot(
|
|
|
|
| 52 |
overlay_point=True,
|
| 53 |
title="Seattle Weather",
|
| 54 |
stroke_dash_legend_title=None,
|
|
|
|
|
|
|
| 55 |
)
|
| 56 |
elif dataset == "gapminder":
|
| 57 |
return gr.LinePlot(
|
|
|
|
| 66 |
overlay_point=False,
|
| 67 |
title="Life expectancy for countries",
|
| 68 |
stroke_dash_legend_title="Country Cluster",
|
|
|
|
|
|
|
| 69 |
)
|
| 70 |
|
| 71 |
|
| 72 |
with gr.Blocks() as line_plot:
|
| 73 |
+
dataset = gr.Dropdown(
|
| 74 |
+
choices=["stocks", "climate", "seattle_weather", "gapminder"],
|
| 75 |
+
value="stocks",
|
| 76 |
+
)
|
| 77 |
+
plot = gr.LinePlot()
|
|
|
|
|
|
|
|
|
|
| 78 |
dataset.change(line_plot_fn, inputs=dataset, outputs=plot)
|
| 79 |
line_plot.load(fn=line_plot_fn, inputs=dataset, outputs=plot)
|
| 80 |
|
requirements.txt
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
-
gradio-client @ git+https://github.com/gradio-app/gradio@
|
| 2 |
-
https://gradio-builds.s3.amazonaws.com/
|
| 3 |
vega_datasets
|
|
|
|
| 1 |
+
gradio-client @ git+https://github.com/gradio-app/gradio@797621b81a0ab9b794e6872f8d43bf6d19a68b78#subdirectory=client/python
|
| 2 |
+
https://gradio-builds.s3.amazonaws.com/797621b81a0ab9b794e6872f8d43bf6d19a68b78/gradio-4.36.1-py3-none-any.whl
|
| 3 |
vega_datasets
|
scatter_plot_demo.py
CHANGED
|
@@ -12,13 +12,14 @@ def scatter_plot_fn(dataset):
|
|
| 12 |
value=iris,
|
| 13 |
x="petalWidth",
|
| 14 |
y="petalLength",
|
| 15 |
-
color=
|
| 16 |
title="Iris Dataset",
|
| 17 |
-
color_legend_title="Species",
|
| 18 |
x_title="Petal Width",
|
| 19 |
y_title="Petal Length",
|
| 20 |
tooltip=["petalWidth", "petalLength", "species"],
|
| 21 |
caption="",
|
|
|
|
|
|
|
| 22 |
)
|
| 23 |
else:
|
| 24 |
return gr.ScatterPlot(
|
|
@@ -29,17 +30,15 @@ def scatter_plot_fn(dataset):
|
|
| 29 |
tooltip="Name",
|
| 30 |
title="Car Data",
|
| 31 |
y_title="Miles per Gallon",
|
| 32 |
-
color_legend_title="Origin of Car",
|
| 33 |
caption="MPG vs Horsepower of various cars",
|
|
|
|
|
|
|
| 34 |
)
|
| 35 |
|
| 36 |
|
| 37 |
with gr.Blocks() as scatter_plot:
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
dataset = gr.Dropdown(choices=["cars", "iris"], value="cars")
|
| 41 |
-
with gr.Column():
|
| 42 |
-
plot = gr.ScatterPlot(show_label=False)
|
| 43 |
dataset.change(scatter_plot_fn, inputs=dataset, outputs=plot)
|
| 44 |
scatter_plot.load(fn=scatter_plot_fn, inputs=dataset, outputs=plot)
|
| 45 |
|
|
|
|
| 12 |
value=iris,
|
| 13 |
x="petalWidth",
|
| 14 |
y="petalLength",
|
| 15 |
+
color=None,
|
| 16 |
title="Iris Dataset",
|
|
|
|
| 17 |
x_title="Petal Width",
|
| 18 |
y_title="Petal Length",
|
| 19 |
tooltip=["petalWidth", "petalLength", "species"],
|
| 20 |
caption="",
|
| 21 |
+
height=600,
|
| 22 |
+
width=600,
|
| 23 |
)
|
| 24 |
else:
|
| 25 |
return gr.ScatterPlot(
|
|
|
|
| 30 |
tooltip="Name",
|
| 31 |
title="Car Data",
|
| 32 |
y_title="Miles per Gallon",
|
|
|
|
| 33 |
caption="MPG vs Horsepower of various cars",
|
| 34 |
+
height=None,
|
| 35 |
+
width=None,
|
| 36 |
)
|
| 37 |
|
| 38 |
|
| 39 |
with gr.Blocks() as scatter_plot:
|
| 40 |
+
dataset = gr.Dropdown(choices=["cars", "iris"], value="cars")
|
| 41 |
+
plot = gr.ScatterPlot(show_label=False)
|
|
|
|
|
|
|
|
|
|
| 42 |
dataset.change(scatter_plot_fn, inputs=dataset, outputs=plot)
|
| 43 |
scatter_plot.load(fn=scatter_plot_fn, inputs=dataset, outputs=plot)
|
| 44 |
|