Spaces:
Sleeping
Sleeping
Download gradio_plotly_dashboard.py from kestrel256/test: direct link, hf CLI and curl.
- Browser
- Download file 727 Bytes
-
https://huggingface.co/spaces/kestrel256/test/resolve/main/gradio_plotly_dashboard.py
- Command line
-
hf download hf://spaces/kestrel256/test/gradio_plotly_dashboard.py
-
curl -L -o gradio_plotly_dashboard.py https://huggingface.co/spaces/kestrel256/test/resolve/main/gradio_plotly_dashboard.py
727 Bytes
| import gradio as gr | |
| import plotly.express as px | |
| import pandas as pd | |
| # sample data | |
| df = px.data.gapminder() | |
| def make_plot(country): | |
| data = df[df.country == country] | |
| fig = px.line(data, x="year", y="gdpPercap", title=f"GDP per Capita: {country}") | |
| return fig | |
| countries = sorted(df.country.unique()) | |
| demo = gr.Interface( | |
| fn=make_plot, | |
| inputs=gr.Dropdown(countries, label="Select a country"), | |
| outputs=gr.Plot(label="GDP per Capita Plot"), | |
| title="Gapminder GDP Dashboard" | |
| ) | |
| # Note that share=True makes a publicly available URL available. | |
| # The URL is publicly available as long as your local gradio session is running. | |
| if __name__ == "__main__": | |
| demo.launch(share=True) | |