mirror of
https://github.com/gradio-app/gradio.git
synced 2025-02-17 11:29:58 +08:00
* changes
* changes
* add changeset
* changes
* changes
* fix box changes on website
* add changeset
* changes
* changes
* Revert "changes"
This reverts commit 189b4e844a
.
* chanegs
* changes
* changes
* changes
* changes
* add changeset
* Update fancy-bats-deny.md
---------
Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
Co-authored-by: aliabd <ali.si3luwa@gmail.com>
Co-authored-by: Abubakar Abid <abubakar@huggingface.co>
48 lines
1.3 KiB
Python
48 lines
1.3 KiB
Python
import gradio as gr
|
|
|
|
from vega_datasets import data
|
|
|
|
cars = data.cars()
|
|
iris = data.iris()
|
|
|
|
|
|
def scatter_plot_fn(dataset):
|
|
if dataset == "iris":
|
|
return gr.ScatterPlot.update(
|
|
value=iris,
|
|
x="petalWidth",
|
|
y="petalLength",
|
|
color="species",
|
|
title="Iris Dataset",
|
|
color_legend_title="Species",
|
|
x_title="Petal Width",
|
|
y_title="Petal Length",
|
|
tooltip=["petalWidth", "petalLength", "species"],
|
|
caption="",
|
|
)
|
|
else:
|
|
return gr.ScatterPlot.update(
|
|
value=cars,
|
|
x="Horsepower",
|
|
y="Miles_per_Gallon",
|
|
color="Origin",
|
|
tooltip="Name",
|
|
title="Car Data",
|
|
y_title="Miles per Gallon",
|
|
color_legend_title="Origin of Car",
|
|
caption="MPG vs Horsepower of various cars",
|
|
)
|
|
|
|
|
|
with gr.Blocks() as scatter_plot:
|
|
with gr.Row():
|
|
with gr.Column():
|
|
dataset = gr.Dropdown(choices=["cars", "iris"], value="cars")
|
|
with gr.Column():
|
|
plot = gr.ScatterPlot(show_label=False)
|
|
dataset.change(scatter_plot_fn, inputs=dataset, outputs=plot)
|
|
scatter_plot.load(fn=scatter_plot_fn, inputs=dataset, outputs=plot)
|
|
|
|
if __name__ == "__main__":
|
|
scatter_plot.launch()
|