Commit ·
72b591e
1
Parent(s): 5e4826f
Upload folder using huggingface_hub
Browse files
README.md
CHANGED
|
@@ -5,7 +5,7 @@ emoji: 🔥
|
|
| 5 |
colorFrom: indigo
|
| 6 |
colorTo: indigo
|
| 7 |
sdk: gradio
|
| 8 |
-
sdk_version: 3.
|
| 9 |
app_file: run.py
|
| 10 |
pinned: false
|
| 11 |
hf_oauth: true
|
|
|
|
| 5 |
colorFrom: indigo
|
| 6 |
colorTo: indigo
|
| 7 |
sdk: gradio
|
| 8 |
+
sdk_version: 3.45.0
|
| 9 |
app_file: run.py
|
| 10 |
pinned: false
|
| 11 |
hf_oauth: true
|
run.ipynb
CHANGED
|
@@ -1 +1 @@
|
|
| 1 |
-
{"cells": [{"cell_type": "markdown", "id": 302934307671667531413257853548643485645, "metadata": {}, "source": ["# Gradio Demo: bar_plot"]}, {"cell_type": "code", "execution_count": null, "id": 272996653310673477252411125948039410165, "metadata": {}, "outputs": [], "source": ["!pip install -q gradio pandas"]}, {"cell_type": "code", "execution_count": null, "id": 288918539441861185822528903084949547379, "metadata": {}, "outputs": [], "source": ["import gradio as gr\n", "import pandas as pd\n", "import random\n", "\n", "simple = pd.DataFrame(\n", " {\n", " \"a\": [\"A\", \"B\", \"C\", \"D\", \"E\", \"F\", \"G\", \"H\", \"I\"],\n", " \"b\": [28, 55, 43, 91, 81, 53, 19, 87, 52],\n", " }\n", ")\n", "\n", "fake_barley = pd.DataFrame(\n", " {\n", " \"site\": [\n", " random.choice(\n", " [\n", " \"University Farm\",\n", " \"Waseca\",\n", " \"Morris\",\n", " \"Crookston\",\n", " \"Grand Rapids\",\n", " \"Duluth\",\n", " ]\n", " )\n", " for _ in range(120)\n", " ],\n", " \"yield\": [random.randint(25, 75) for _ in range(120)],\n", " \"variety\": [\n", " random.choice(\n", " [\n", " \"Manchuria\",\n", " \"Wisconsin No. 38\",\n", " \"Glabron\",\n", " \"No. 457\",\n", " \"No. 462\",\n", " \"No. 475\",\n", " ]\n", " )\n", " for _ in range(120)\n", " ],\n", " \"year\": [\n", " random.choice(\n", " [\n", " \"1931\",\n", " \"1932\",\n", " ]\n", " )\n", " for _ in range(120)\n", " ],\n", " }\n", ")\n", "\n", "\n", "def bar_plot_fn(display):\n", " if display == \"simple\":\n", " return gr.BarPlot
|
|
|
|
| 1 |
+
{"cells": [{"cell_type": "markdown", "id": 302934307671667531413257853548643485645, "metadata": {}, "source": ["# Gradio Demo: bar_plot"]}, {"cell_type": "code", "execution_count": null, "id": 272996653310673477252411125948039410165, "metadata": {}, "outputs": [], "source": ["!pip install -q gradio pandas"]}, {"cell_type": "code", "execution_count": null, "id": 288918539441861185822528903084949547379, "metadata": {}, "outputs": [], "source": ["import gradio as gr\n", "import pandas as pd\n", "import random\n", "\n", "simple = pd.DataFrame(\n", " {\n", " \"a\": [\"A\", \"B\", \"C\", \"D\", \"E\", \"F\", \"G\", \"H\", \"I\"],\n", " \"b\": [28, 55, 43, 91, 81, 53, 19, 87, 52],\n", " }\n", ")\n", "\n", "fake_barley = pd.DataFrame(\n", " {\n", " \"site\": [\n", " random.choice(\n", " [\n", " \"University Farm\",\n", " \"Waseca\",\n", " \"Morris\",\n", " \"Crookston\",\n", " \"Grand Rapids\",\n", " \"Duluth\",\n", " ]\n", " )\n", " for _ in range(120)\n", " ],\n", " \"yield\": [random.randint(25, 75) for _ in range(120)],\n", " \"variety\": [\n", " random.choice(\n", " [\n", " \"Manchuria\",\n", " \"Wisconsin No. 38\",\n", " \"Glabron\",\n", " \"No. 457\",\n", " \"No. 462\",\n", " \"No. 475\",\n", " ]\n", " )\n", " for _ in range(120)\n", " ],\n", " \"year\": [\n", " random.choice(\n", " [\n", " \"1931\",\n", " \"1932\",\n", " ]\n", " )\n", " for _ in range(120)\n", " ],\n", " }\n", ")\n", "\n", "\n", "def bar_plot_fn(display):\n", " if display == \"simple\":\n", " return gr.BarPlot(\n", " simple,\n", " x=\"a\",\n", " y=\"b\",\n", " title=\"Simple Bar Plot with made up data\",\n", " tooltip=[\"a\", \"b\"],\n", " y_lim=[20, 100],\n", " )\n", " elif display == \"stacked\":\n", " return gr.BarPlot(\n", " fake_barley,\n", " x=\"variety\",\n", " y=\"yield\",\n", " color=\"site\",\n", " title=\"Barley Yield Data\",\n", " tooltip=[\"variety\", \"site\"],\n", " )\n", " elif display == \"grouped\":\n", " return gr.BarPlot(\n", " fake_barley.astype({\"year\": str}),\n", " x=\"year\",\n", " y=\"yield\",\n", " color=\"year\",\n", " group=\"site\",\n", " title=\"Barley Yield by Year and Site\",\n", " group_title=\"\",\n", " tooltip=[\"yield\", \"site\", \"year\"],\n", " )\n", " elif display == \"simple-horizontal\":\n", " return gr.BarPlot(\n", " simple,\n", " x=\"a\",\n", " y=\"b\",\n", " x_title=\"Variable A\",\n", " y_title=\"Variable B\",\n", " title=\"Simple Bar Plot with made up data\",\n", " tooltip=[\"a\", \"b\"],\n", " vertical=False,\n", " y_lim=[20, 100],\n", " )\n", " elif display == \"stacked-horizontal\":\n", " return gr.BarPlot(\n", " fake_barley,\n", " x=\"variety\",\n", " y=\"yield\",\n", " color=\"site\",\n", " title=\"Barley Yield Data\",\n", " vertical=False,\n", " tooltip=[\"variety\", \"site\"],\n", " )\n", " elif display == \"grouped-horizontal\":\n", " return gr.BarPlot(\n", " fake_barley.astype({\"year\": str}),\n", " x=\"year\",\n", " y=\"yield\",\n", " color=\"year\",\n", " group=\"site\",\n", " title=\"Barley Yield by Year and Site\",\n", " group_title=\"\",\n", " tooltip=[\"yield\", \"site\", \"year\"],\n", " vertical=False,\n", " )\n", "\n", "\n", "with gr.Blocks() as bar_plot:\n", " with gr.Row():\n", " with gr.Column():\n", " display = gr.Dropdown(\n", " choices=[\n", " \"simple\",\n", " \"stacked\",\n", " \"grouped\",\n", " \"simple-horizontal\",\n", " \"stacked-horizontal\",\n", " \"grouped-horizontal\",\n", " ],\n", " value=\"simple\",\n", " label=\"Type of Bar Plot\",\n", " )\n", " with gr.Column():\n", " plot = gr.BarPlot()\n", " display.change(bar_plot_fn, inputs=display, outputs=plot)\n", " bar_plot.load(fn=bar_plot_fn, inputs=display, outputs=plot)\n", "\n", "bar_plot.launch()\n"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}
|
run.py
CHANGED
|
@@ -53,7 +53,7 @@ fake_barley = pd.DataFrame(
|
|
| 53 |
|
| 54 |
def bar_plot_fn(display):
|
| 55 |
if display == "simple":
|
| 56 |
-
return gr.BarPlot
|
| 57 |
simple,
|
| 58 |
x="a",
|
| 59 |
y="b",
|
|
@@ -62,7 +62,7 @@ def bar_plot_fn(display):
|
|
| 62 |
y_lim=[20, 100],
|
| 63 |
)
|
| 64 |
elif display == "stacked":
|
| 65 |
-
return gr.BarPlot
|
| 66 |
fake_barley,
|
| 67 |
x="variety",
|
| 68 |
y="yield",
|
|
@@ -71,7 +71,7 @@ def bar_plot_fn(display):
|
|
| 71 |
tooltip=["variety", "site"],
|
| 72 |
)
|
| 73 |
elif display == "grouped":
|
| 74 |
-
return gr.BarPlot
|
| 75 |
fake_barley.astype({"year": str}),
|
| 76 |
x="year",
|
| 77 |
y="yield",
|
|
@@ -82,7 +82,7 @@ def bar_plot_fn(display):
|
|
| 82 |
tooltip=["yield", "site", "year"],
|
| 83 |
)
|
| 84 |
elif display == "simple-horizontal":
|
| 85 |
-
return gr.BarPlot
|
| 86 |
simple,
|
| 87 |
x="a",
|
| 88 |
y="b",
|
|
@@ -94,7 +94,7 @@ def bar_plot_fn(display):
|
|
| 94 |
y_lim=[20, 100],
|
| 95 |
)
|
| 96 |
elif display == "stacked-horizontal":
|
| 97 |
-
return gr.BarPlot
|
| 98 |
fake_barley,
|
| 99 |
x="variety",
|
| 100 |
y="yield",
|
|
@@ -104,7 +104,7 @@ def bar_plot_fn(display):
|
|
| 104 |
tooltip=["variety", "site"],
|
| 105 |
)
|
| 106 |
elif display == "grouped-horizontal":
|
| 107 |
-
return gr.BarPlot
|
| 108 |
fake_barley.astype({"year": str}),
|
| 109 |
x="year",
|
| 110 |
y="yield",
|
|
|
|
| 53 |
|
| 54 |
def bar_plot_fn(display):
|
| 55 |
if display == "simple":
|
| 56 |
+
return gr.BarPlot(
|
| 57 |
simple,
|
| 58 |
x="a",
|
| 59 |
y="b",
|
|
|
|
| 62 |
y_lim=[20, 100],
|
| 63 |
)
|
| 64 |
elif display == "stacked":
|
| 65 |
+
return gr.BarPlot(
|
| 66 |
fake_barley,
|
| 67 |
x="variety",
|
| 68 |
y="yield",
|
|
|
|
| 71 |
tooltip=["variety", "site"],
|
| 72 |
)
|
| 73 |
elif display == "grouped":
|
| 74 |
+
return gr.BarPlot(
|
| 75 |
fake_barley.astype({"year": str}),
|
| 76 |
x="year",
|
| 77 |
y="yield",
|
|
|
|
| 82 |
tooltip=["yield", "site", "year"],
|
| 83 |
)
|
| 84 |
elif display == "simple-horizontal":
|
| 85 |
+
return gr.BarPlot(
|
| 86 |
simple,
|
| 87 |
x="a",
|
| 88 |
y="b",
|
|
|
|
| 94 |
y_lim=[20, 100],
|
| 95 |
)
|
| 96 |
elif display == "stacked-horizontal":
|
| 97 |
+
return gr.BarPlot(
|
| 98 |
fake_barley,
|
| 99 |
x="variety",
|
| 100 |
y="yield",
|
|
|
|
| 104 |
tooltip=["variety", "site"],
|
| 105 |
)
|
| 106 |
elif display == "grouped-horizontal":
|
| 107 |
+
return gr.BarPlot(
|
| 108 |
fake_barley.astype({"year": str}),
|
| 109 |
x="year",
|
| 110 |
y="yield",
|