Skip to content

gr.Plot with an autosize Plotly figure renders at zero height in 6.18.0 #13539

Description

@hysts

Describe the bug

A gr.Plot that shows a Plotly figure with no explicit height in its layout (so it relies on Plotly autosize) renders with zero height in Gradio 6.18.0. The plot area is blank. Giving the figure a fixed height with fig.update_layout(height=...) avoids the problem, but that loses responsive height.
This is a regression. The same code renders correctly in 6.17.3.

Have you searched existing issues? 🔎

  • I have searched and found no existing issues

Reproduction

import gradio as gr
import plotly.express as px

df = px.data.gapminder().query("country == 'Canada'")

with gr.Blocks() as demo:
    # No layout height set, so Plotly autosize is used. Renders blank on 6.18.0.
    gr.Plot(px.line(df, x="year", y="lifeExp", title="autosize"))

    # Works on 6.18.0 because the height is fixed.
    fig = px.line(df, x="year", y="lifeExp", title="fixed height")
    fig.update_layout(height=320)
    gr.Plot(fig)

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

Screenshot

gradio==6.17.3

Image

gradio==6.18.0

Image

Logs

System Info

gradio==6.18.0

Severity

I can work around it

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingtodofeatures or bug fixes that we should tackle immediately either manually or with agents

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions