-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gr.ScatterPlot component #2764
Merged
Merged
gr.ScatterPlot component #2764
Changes from 22 commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
5fbc4e4
Try clean install
freddyaboulton 3dd95fc
Resolve peer dependencies?
freddyaboulton 50b6006
CHANGELOG
freddyaboulton 1d56cde
Add outbreak_forcast notebook
freddyaboulton bfa84f7
generate again
freddyaboulton ee242ba
CHANGELOG
freddyaboulton 1f832c9
Add image to changelog
freddyaboulton 18079f7
Color palette
freddyaboulton 44a043c
Fix colors + legend
freddyaboulton 7f2a058
Tooltip
freddyaboulton d7f985a
Add axis titles
freddyaboulton 80a0095
Clean up code a bit + quant scales
freddyaboulton c8f8a18
Add code
freddyaboulton f455f4d
Add size, shape + rename legend title
freddyaboulton f546f03
Fix demo
freddyaboulton 289f075
Add update + demo
freddyaboulton c4006e8
Handle darkmode better
freddyaboulton 6dbf58c
Try new font
freddyaboulton 7401b80
Use sans-serif
freddyaboulton 3e1f397
Add caption
freddyaboulton 611e764
Changelog + tests
freddyaboulton 4ef2d91
More tests
freddyaboulton d56eb10
Address comments
freddyaboulton 08ffebb
Make caption fontsize smaller and enable interactivity
freddyaboulton 130ee75
Add docstrings + add height + width
freddyaboulton 076ab56
Merge branch 'main' into scatter-plot
abidlabs 5dc41e2
Use normal font weight
freddyaboulton 8715506
Merge main
freddyaboulton 0b73f5e
Merge branch 'main' into scatter-plot
freddyaboulton 620f656
Merge upstream changelog
freddyaboulton ec01da3
Make last values keyword only
freddyaboulton 8146fda
Fix typo
freddyaboulton 920cd92
Accept value as fn
freddyaboulton f2cb2e9
reword changelog a bit
freddyaboulton File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
vega_datasets |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +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/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_plot\n", "\n", "\n", "with gr.Blocks() as demo:\n", " with gr.Tabs():\n", " with gr.TabItem(\"Scatter Plot\"):\n", " scatter_plot.render()\n", "\n", "if __name__ == \"__main__\":\n", " demo.launch()\n"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import gradio as gr | ||
|
||
from scatter_plot_demo import scatter_plot | ||
|
||
|
||
with gr.Blocks() as demo: | ||
with gr.Tabs(): | ||
with gr.TabItem("Scatter Plot"): | ||
scatter_plot.render() | ||
|
||
if __name__ == "__main__": | ||
demo.launch() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
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).style(container=True) | ||
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
vega_datasets |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"cells": [{"cell_type": "markdown", "id": 302934307671667531413257853548643485645, "metadata": {}, "source": ["# Gradio Demo: scatterplot_component"]}, {"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": ["import gradio as gr\n", "from vega_datasets import data\n", "\n", "cars = data.cars()\n", "\n", "with gr.Blocks() as demo:\n", " gr.ScatterPlot(show_label=False,\n", " value=cars,\n", " x=\"Horsepower\",\n", " y=\"Miles_per_Gallon\",\n", " color=\"Origin\",\n", " tooltip=\"Name\",\n", " title=\"Car Data\",\n", " y_title=\"Miles per Gallon\",\n", " color_legend_title=\"Origin of Car\").style(container=False)\n", "\n", "if __name__ == \"__main__\":\n", " demo.launch()"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import gradio as gr | ||
from vega_datasets import data | ||
|
||
cars = data.cars() | ||
|
||
with gr.Blocks() as demo: | ||
gr.ScatterPlot(show_label=False, | ||
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").style(container=False) | ||
|
||
if __name__ == "__main__": | ||
demo.launch() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,6 +35,7 @@ | |
Number, | ||
Plot, | ||
Radio, | ||
ScatterPlot, | ||
Slider, | ||
State, | ||
StatusTracker, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a suggestion, feel free to ignore