gradio/demo/plot_guide_zoom/run.ipynb
aliabid94 4ba7b238e2
Improve plot guide, add double clicking to plots (#9064)
* changes

* add changeset

* chages

* changes

* changes

* changes

* changes

---------

Co-authored-by: Ali Abid <aliabid94@gmail.com>
Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
2024-08-07 19:17:14 -07:00

1.3 KiB

Gradio Demo: plot_guide_zoom

In [ ]:
!pip install -q gradio 
In [ ]:
# Downloading files from the demo repo
import os
!wget -q https://github.com/gradio-app/gradio/raw/main/demo/plot_guide_zoom/data.py
In [ ]:
import gradio as gr
from data import df

with gr.Blocks() as demo:
    plt = gr.LinePlot(df, x="weight", y="height")

    def select_region(selection: gr.SelectData):
        min_w, max_w = selection.index
        return gr.LinePlot(x_lim=(min_w, max_w)) # type: ignore

    plt.select(select_region, None, plt)
    plt.double_click(lambda: gr.LinePlot(x_lim=None), None, plt)

if __name__ == "__main__":
    demo.launch()