aliabd HF Staff commited on
Commit
d275735
·
verified ·
1 Parent(s): 9264628

Upload folder using huggingface_hub

Browse files
Files changed (7) hide show
  1. bar_plot_demo.py +4 -7
  2. data.py +2 -2
  3. line_plot_demo.py +4 -7
  4. requirements.txt +2 -2
  5. run.ipynb +1 -1
  6. run.py +0 -1
  7. scatter_plot_demo.py +4 -7
bar_plot_demo.py CHANGED
@@ -1,5 +1,4 @@
1
  import gradio as gr
2
- import numpy as np
3
  from data import temp_sensor_data, food_rating_data
4
 
5
  with gr.Blocks() as bar_plots:
@@ -25,17 +24,16 @@ with gr.Blocks() as bar_plots:
25
 
26
  time_graphs = [temp_by_time, temp_by_time_location]
27
  group_by.change(
28
- lambda group: [gr.BarPlot(x_bin=None if group == "None" else group)] * len(time_graphs),
29
- group_by,
30
  time_graphs
31
  )
32
  aggregate.change(
33
- lambda aggregate: [gr.BarPlot(y_aggregate=aggregate)] * len(time_graphs),
34
- aggregate,
35
  time_graphs
36
  )
37
 
38
-
39
  def rescale(select: gr.SelectData):
40
  return select.index
41
  rescale_evt = gr.on([plot.select for plot in time_graphs], rescale, None, [start, end])
@@ -72,6 +70,5 @@ with gr.Blocks() as bar_plots:
72
  color_map={"Italian": "red", "Mexican": "green", "Chinese": "blue"},
73
  )
74
 
75
-
76
  if __name__ == "__main__":
77
  bar_plots.launch()
 
1
  import gradio as gr
 
2
  from data import temp_sensor_data, food_rating_data
3
 
4
  with gr.Blocks() as bar_plots:
 
24
 
25
  time_graphs = [temp_by_time, temp_by_time_location]
26
  group_by.change(
27
+ lambda group: [gr.BarPlot(x_bin=None if group == "None" else group)] * len(time_graphs),
28
+ group_by,
29
  time_graphs
30
  )
31
  aggregate.change(
32
+ lambda aggregate: [gr.BarPlot(y_aggregate=aggregate)] * len(time_graphs),
33
+ aggregate,
34
  time_graphs
35
  )
36
 
 
37
  def rescale(select: gr.SelectData):
38
  return select.index
39
  rescale_evt = gr.on([plot.select for plot in time_graphs], rescale, None, [start, end])
 
70
  color_map={"Italian": "red", "Mexican": "green", "Chinese": "blue"},
71
  )
72
 
 
73
  if __name__ == "__main__":
74
  bar_plots.launch()
data.py CHANGED
@@ -1,5 +1,5 @@
1
  import pandas as pd
2
- from random import randint, choice, random
3
 
4
  temp_sensor_data = pd.DataFrame(
5
  {
@@ -17,4 +17,4 @@ food_rating_data = pd.DataFrame(
17
  "price": [randint(10, 50) + 4 * (i % 3) for i in range(100)],
18
  "wait": [random() for i in range(100)],
19
  }
20
- )
 
1
  import pandas as pd
2
+ from random import randint, random
3
 
4
  temp_sensor_data = pd.DataFrame(
5
  {
 
17
  "price": [randint(10, 50) + 4 * (i % 3) for i in range(100)],
18
  "wait": [random() for i in range(100)],
19
  }
20
+ )
line_plot_demo.py CHANGED
@@ -1,5 +1,4 @@
1
  import gradio as gr
2
- import numpy as np
3
  from data import temp_sensor_data, food_rating_data
4
 
5
  with gr.Blocks() as line_plots:
@@ -25,17 +24,16 @@ with gr.Blocks() as line_plots:
25
 
26
  time_graphs = [temp_by_time, temp_by_time_location]
27
  group_by.change(
28
- lambda group: [gr.LinePlot(x_bin=None if group == "None" else group)] * len(time_graphs),
29
- group_by,
30
  time_graphs
31
  )
32
  aggregate.change(
33
- lambda aggregate: [gr.LinePlot(y_aggregate=aggregate)] * len(time_graphs),
34
- aggregate,
35
  time_graphs
36
  )
37
 
38
-
39
  def rescale(select: gr.SelectData):
40
  return select.index
41
  rescale_evt = gr.on([plot.select for plot in time_graphs], rescale, None, [start, end])
@@ -64,6 +62,5 @@ with gr.Blocks() as line_plots:
64
  color_map={"Italian": "red", "Mexican": "green", "Chinese": "blue"},
65
  )
66
 
67
-
68
  if __name__ == "__main__":
69
  line_plots.launch()
 
1
  import gradio as gr
 
2
  from data import temp_sensor_data, food_rating_data
3
 
4
  with gr.Blocks() as line_plots:
 
24
 
25
  time_graphs = [temp_by_time, temp_by_time_location]
26
  group_by.change(
27
+ lambda group: [gr.LinePlot(x_bin=None if group == "None" else group)] * len(time_graphs),
28
+ group_by,
29
  time_graphs
30
  )
31
  aggregate.change(
32
+ lambda aggregate: [gr.LinePlot(y_aggregate=aggregate)] * len(time_graphs),
33
+ aggregate,
34
  time_graphs
35
  )
36
 
 
37
  def rescale(select: gr.SelectData):
38
  return select.index
39
  rescale_evt = gr.on([plot.select for plot in time_graphs], rescale, None, [start, end])
 
62
  color_map={"Italian": "red", "Mexican": "green", "Chinese": "blue"},
63
  )
64
 
 
65
  if __name__ == "__main__":
66
  line_plots.launch()
requirements.txt CHANGED
@@ -1,3 +1,3 @@
1
- gradio-client @ git+https://github.com/gradio-app/gradio@de997e67c9a7feb9e2eccebf92969366dbd67eba#subdirectory=client/python
2
- https://gradio-builds.s3.amazonaws.com/de997e67c9a7feb9e2eccebf92969366dbd67eba/gradio-4.39.0-py3-none-any.whl
3
  vega_datasets
 
1
+ gradio-client @ git+https://github.com/gradio-app/gradio@9b42ba8f1006c05d60a62450d3036ce0d6784f86#subdirectory=client/python
2
+ https://gradio-builds.s3.amazonaws.com/9b42ba8f1006c05d60a62450d3036ce0d6784f86/gradio-4.39.0-py3-none-any.whl
3
  vega_datasets
run.ipynb CHANGED
@@ -1 +1 @@
1
- {"cells": [{"cell_type": "markdown", "id": "302934307671667531413257853548643485645", "metadata": {}, "source": ["# Gradio Demo: native_plots"]}, {"cell_type": "code", "execution_count": null, "id": "272996653310673477252411125948039410165", "metadata": {}, "outputs": [], "source": ["!pip install -q gradio vega_datasets"]}, {"cell_type": "code", "execution_count": null, "id": "288918539441861185822528903084949547379", "metadata": {}, "outputs": [], "source": ["# Downloading files from the demo repo\n", "import os\n", "!wget -q https://github.com/gradio-app/gradio/raw/main/demo/native_plots/bar_plot_demo.py\n", "!wget -q https://github.com/gradio-app/gradio/raw/main/demo/native_plots/data.py\n", "!wget -q https://github.com/gradio-app/gradio/raw/main/demo/native_plots/line_plot_demo.py\n", "!wget -q https://github.com/gradio-app/gradio/raw/main/demo/native_plots/scatter_plot_demo.py"]}, {"cell_type": "code", "execution_count": null, "id": "44380577570523278879349135829904343037", "metadata": {}, "outputs": [], "source": ["import gradio as gr\n", "\n", "from scatter_plot_demo import scatter_plots\n", "from line_plot_demo import line_plots\n", "from bar_plot_demo import bar_plots\n", "\n", "\n", "with gr.Blocks() as demo:\n", " with gr.Tabs():\n", " with gr.TabItem(\"Line Plot\"):\n", " line_plots.render()\n", " with gr.TabItem(\"Scatter Plot\"):\n", " scatter_plots.render()\n", " with gr.TabItem(\"Bar Plot\"):\n", " bar_plots.render()\n", "\n", "if __name__ == \"__main__\":\n", " demo.launch()\n"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}
 
1
+ {"cells": [{"cell_type": "markdown", "id": "302934307671667531413257853548643485645", "metadata": {}, "source": ["# Gradio Demo: native_plots"]}, {"cell_type": "code", "execution_count": null, "id": "272996653310673477252411125948039410165", "metadata": {}, "outputs": [], "source": ["!pip install -q gradio vega_datasets"]}, {"cell_type": "code", "execution_count": null, "id": "288918539441861185822528903084949547379", "metadata": {}, "outputs": [], "source": ["# Downloading files from the demo repo\n", "import os\n", "!wget -q https://github.com/gradio-app/gradio/raw/main/demo/native_plots/bar_plot_demo.py\n", "!wget -q https://github.com/gradio-app/gradio/raw/main/demo/native_plots/data.py\n", "!wget -q https://github.com/gradio-app/gradio/raw/main/demo/native_plots/line_plot_demo.py\n", "!wget -q https://github.com/gradio-app/gradio/raw/main/demo/native_plots/scatter_plot_demo.py"]}, {"cell_type": "code", "execution_count": null, "id": "44380577570523278879349135829904343037", "metadata": {}, "outputs": [], "source": ["import gradio as gr\n", "\n", "from scatter_plot_demo import scatter_plots\n", "from line_plot_demo import line_plots\n", "from bar_plot_demo import bar_plots\n", "\n", "with gr.Blocks() as demo:\n", " with gr.Tabs():\n", " with gr.TabItem(\"Line Plot\"):\n", " line_plots.render()\n", " with gr.TabItem(\"Scatter Plot\"):\n", " scatter_plots.render()\n", " with gr.TabItem(\"Bar Plot\"):\n", " bar_plots.render()\n", "\n", "if __name__ == \"__main__\":\n", " demo.launch()\n"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}
run.py CHANGED
@@ -4,7 +4,6 @@ from scatter_plot_demo import scatter_plots
4
  from line_plot_demo import line_plots
5
  from bar_plot_demo import bar_plots
6
 
7
-
8
  with gr.Blocks() as demo:
9
  with gr.Tabs():
10
  with gr.TabItem("Line Plot"):
 
4
  from line_plot_demo import line_plots
5
  from bar_plot_demo import bar_plots
6
 
 
7
  with gr.Blocks() as demo:
8
  with gr.Tabs():
9
  with gr.TabItem("Line Plot"):
scatter_plot_demo.py CHANGED
@@ -1,5 +1,4 @@
1
  import gradio as gr
2
- import numpy as np
3
  from data import temp_sensor_data, food_rating_data
4
 
5
  with gr.Blocks() as scatter_plots:
@@ -25,17 +24,16 @@ with gr.Blocks() as scatter_plots:
25
 
26
  time_graphs = [temp_by_time, temp_by_time_location]
27
  group_by.change(
28
- lambda group: [gr.ScatterPlot(x_bin=None if group == "None" else group)] * len(time_graphs),
29
- group_by,
30
  time_graphs
31
  )
32
  aggregate.change(
33
- lambda aggregate: [gr.ScatterPlot(y_aggregate=aggregate)] * len(time_graphs),
34
- aggregate,
35
  time_graphs
36
  )
37
 
38
-
39
  # def rescale(select: gr.SelectData):
40
  # return select.index
41
  # rescale_evt = gr.on([plot.select for plot in time_graphs], rescale, None, [start, end])
@@ -66,6 +64,5 @@ with gr.Blocks() as scatter_plots:
66
  # color_map={"Italian": "red", "Mexican": "green", "Chinese": "blue"},
67
  )
68
 
69
-
70
  if __name__ == "__main__":
71
  scatter_plots.launch()
 
1
  import gradio as gr
 
2
  from data import temp_sensor_data, food_rating_data
3
 
4
  with gr.Blocks() as scatter_plots:
 
24
 
25
  time_graphs = [temp_by_time, temp_by_time_location]
26
  group_by.change(
27
+ lambda group: [gr.ScatterPlot(x_bin=None if group == "None" else group)] * len(time_graphs),
28
+ group_by,
29
  time_graphs
30
  )
31
  aggregate.change(
32
+ lambda aggregate: [gr.ScatterPlot(y_aggregate=aggregate)] * len(time_graphs),
33
+ aggregate,
34
  time_graphs
35
  )
36
 
 
37
  # def rescale(select: gr.SelectData):
38
  # return select.index
39
  # rescale_evt = gr.on([plot.select for plot in time_graphs], rescale, None, [start, end])
 
64
  # color_map={"Italian": "red", "Mexican": "green", "Chinese": "blue"},
65
  )
66
 
 
67
  if __name__ == "__main__":
68
  scatter_plots.launch()