import gradio as gr from bokeh.plotting import figure def get_plot(plot_type): plot = figure() x=[1,2,3,4] y=[2,4,5,6] if (plot_type=="scatter"): plot.scatter(x=x, y=y) if (plot_type=="line"): plot.line(x=x, y=y) if (plot_type=="bar"): plot.vbar(x=x, top=y , bottom=0) return plot with gr.Blocks() as demo: with gr.Row(): plot_type = gr.Radio(value="scatter", choices=["scatter", "line", "bar"]) plot = gr.Plot() plot_type.change(get_plot, inputs=[plot_type], outputs=[plot]) demo.load(get_plot, inputs=[plot_type], outputs=[plot]) demo.launch()