Skip to content
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
5fbc4e4
Try clean install
freddyaboulton Nov 29, 2022
3dd95fc
Resolve peer dependencies?
freddyaboulton Nov 29, 2022
50b6006
CHANGELOG
freddyaboulton Nov 29, 2022
1d56cde
Add outbreak_forcast notebook
freddyaboulton Dec 2, 2022
bfa84f7
generate again
freddyaboulton Dec 2, 2022
ee242ba
CHANGELOG
freddyaboulton Nov 29, 2022
1f832c9
Add image to changelog
freddyaboulton Nov 29, 2022
18079f7
Color palette
freddyaboulton Dec 1, 2022
44a043c
Fix colors + legend
freddyaboulton Dec 2, 2022
7f2a058
Tooltip
freddyaboulton Dec 2, 2022
d7f985a
Add axis titles
freddyaboulton Dec 2, 2022
80a0095
Clean up code a bit + quant scales
freddyaboulton Dec 5, 2022
c8f8a18
Add code
freddyaboulton Dec 5, 2022
f455f4d
Add size, shape + rename legend title
freddyaboulton Dec 5, 2022
f546f03
Fix demo
freddyaboulton Dec 5, 2022
289f075
Add update + demo
freddyaboulton Dec 7, 2022
c4006e8
Handle darkmode better
freddyaboulton Dec 7, 2022
6dbf58c
Try new font
freddyaboulton Dec 7, 2022
7401b80
Use sans-serif
freddyaboulton Dec 7, 2022
3e1f397
Add caption
freddyaboulton Dec 7, 2022
611e764
Changelog + tests
freddyaboulton Dec 7, 2022
4ef2d91
More tests
freddyaboulton Dec 7, 2022
d56eb10
Address comments
freddyaboulton Dec 8, 2022
08ffebb
Make caption fontsize smaller and enable interactivity
freddyaboulton Dec 8, 2022
130ee75
Add docstrings + add height + width
freddyaboulton Dec 8, 2022
076ab56
Merge branch 'main' into scatter-plot
abidlabs Dec 9, 2022
5dc41e2
Use normal font weight
freddyaboulton Dec 9, 2022
8715506
Merge main
freddyaboulton Dec 9, 2022
0b73f5e
Merge branch 'main' into scatter-plot
freddyaboulton Dec 9, 2022
620f656
Merge upstream changelog
freddyaboulton Dec 9, 2022
ec01da3
Make last values keyword only
freddyaboulton Dec 9, 2022
8146fda
Fix typo
freddyaboulton Dec 9, 2022
920cd92
Accept value as fn
freddyaboulton Dec 9, 2022
f2cb2e9
reword changelog a bit
freddyaboulton Dec 9, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 36 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,41 @@

## New Features:

### Scatter plot component

It is now possible to create a scatter plot without knowledge of a plotting library!
Copy link
Copy Markdown
Member

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

Suggested change
It is now possible to create a scatter plot without knowledge of a plotting library!
It is now possible to create a scatter plot natively in Gradio!


The `gr.ScatterPlot` component accepts a pandas dataframe and some optional configuration parameters
and will automatically create a plot for you!

This is the first of many native plotting components in Gradio!

For an example of how to use `gr.ScatterPlot` see below:

```python
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)

demo.launch()
```

By [@freddyaboulton](https://github.com/freddyaboulton) in [PR 2764](https://github.com/gradio-app/gradio/pull/2764)



### Support for altair plots

The `Plot` component can now accept altair plots as values!
Expand Down Expand Up @@ -33,7 +68,7 @@ demo.launch()

By [@freddyaboulton](https://github.com/freddyaboulton) in [PR 2741](https://github.com/gradio-app/gradio/pull/2741)

### Set the background color of a Label component
### Set the background color of a Label component

The `Label` component now accepts a `color` argument by [@freddyaboulton](https://github.com/freddyaboulton) in [PR 2736](https://github.com/gradio-app/gradio/pull/2736).
The `color` argument should either be a valid css color name or hexadecimal string.
Expand Down Expand Up @@ -70,7 +105,6 @@ demo.queue().launch()

![label_bg_color_update](https://user-images.githubusercontent.com/41651716/204400372-80e53857-f26f-4a38-a1ae-1acadff75e89.gif)


## Bug Fixes:
* Fixed issue where image thumbnails were not showing when an example directory was provided
by by [@abidlabs](https://github.com/abidlabs) in [PR 2745](https://github.com/gradio-app/gradio/pull/2745)
Expand Down
1 change: 1 addition & 0 deletions demo/native_plots/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
vega_datasets
1 change: 1 addition & 0 deletions demo/native_plots/run.ipynb
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}
12 changes: 12 additions & 0 deletions demo/native_plots/run.py
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()
47 changes: 47 additions & 0 deletions demo/native_plots/scatter_plot_demo.py
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()
1 change: 1 addition & 0 deletions demo/scatterplot_component/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
vega_datasets
1 change: 1 addition & 0 deletions demo/scatterplot_component/run.ipynb
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}
18 changes: 18 additions & 0 deletions demo/scatterplot_component/run.py
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()
1 change: 1 addition & 0 deletions gradio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
Number,
Plot,
Radio,
ScatterPlot,
Slider,
State,
StatusTracker,
Expand Down
Loading