Spaces:
Sleeping
Sleeping
Download run.py from gradio/plot_guide_selection_main: direct link, hf CLI and curl.
- Browser
- Download file 473 Bytes
-
https://huggingface.co/spaces/gradio/plot_guide_selection_main/resolve/e8a00a41f2bc901014e0516c865a9038073df51d/run.py
- Command line
-
hf download hf://spaces/gradio/plot_guide_selection_main@e8a00a41f2bc901014e0516c865a9038073df51d/run.py
-
curl -L -o run.py https://huggingface.co/spaces/gradio/plot_guide_selection_main/resolve/e8a00a41f2bc901014e0516c865a9038073df51d/run.py
473 Bytes
| import gradio as gr | |
| from data import df # type: ignore | |
| with gr.Blocks() as demo: | |
| plt = gr.LinePlot(df, x="weight", y="height") | |
| selection_total = gr.Number(label="Total Weight of Selection") | |
| def select_region(selection: gr.SelectData): | |
| min_w, max_w = selection.index | |
| return df[(df["weight"] >= min_w) & (df["weight"] <= max_w)]["weight"].sum() | |
| plt.select(select_region, None, selection_total) | |
| if __name__ == "__main__": | |
| demo.launch() |