import gradio as gr from bokeh.plotting import figure from bokeh.plotting import figure def get_plot(plot_type): plot = figure(sizing_mode='stretch_both') 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 css = """ #plotly_Graph div:nth-of-type(2){ HEIGHT:200px; } @media(min-width:1200px){ #plotly_Graph div:nth-of-type(2){ HEIGHT:400px; } } """ with gr.Blocks(css=css) as demo: with gr.Row(): plot_type = gr.Radio(value="scatter", choices=["scatter", "line", "bar"]) plot = gr.Plot(elem_id="plotly_Graph") plot_type.change(get_plot, inputs=[plot_type], outputs=[plot]) demo.load(get_plot, inputs=[plot_type], outputs=[plot]) demo.launch()