Skip to content

Only the last 8 line graphs are displayed in vscode notebook editor #3440

Description

@ekutner

The issue:

When rendering more than 8 line graphs in vscode notebook editor a very strange thing happens.
As long as the number of graphs remain under 8 they are all displayed properly. As additional graphs are added the first ones loose their content so that only the last 8 are properly displayed. The graphs that loose their content don't just disappear, they still display the background, grid, legend, and even when hovering with the mouse over the empty graph the popup label is displayed properly, only the lines are missing. The attached screenshot shows such a graph that lost its content.

Reproducing:

import plotly.express as px

df = px.data.gapminder()
for i in range(0,10):
    fig = px.line(df, x="year", y=["lifeExp", "gdpPercap"], title='Life expectancy in Canada')
    fig.show()

Version info:

  • vscode: latest (1.61.2)
  • python: 3.6.8
  • plotly: latest (5.3.1)

Additional info:

  • This only happens with "complex" graphs. If you remove one of the fields from the y axis in the above example it won't happen any more.
  • It doesn't seem to happen with other types of graphs, at least not with bar charts.
  • I didn't test this directly in Jupyter so don't know if the issue happens there as well.
  • Explicitly setting plotly.io.renderers.default = "vscode" doesn't help

Screenshot 2021-10-24 194422

Activity

  1. nicolaskruchten commented on Oct 25, 2021

    @nicolaskruchten
    Contributor

    This is unfortunately a hard limitation of browsers rendering WebGL plots... See documentation here re "context limits": https://plotly.com/python/webgl-vs-svg/

  2. ekutner commented on Oct 25, 2021

    @ekutner
    Author

    I see, thank you. Setting render_mode='svg' indeed solves the issue.

    That said, it seems that the current behavior doesn't make a lot of sense. I'd argue that most people would rather the graphs are displayed, even if a bit slower, rather than disappearing altogether with no explanation. Would it be possible to keep a global counter of the number of webgl rendered graphs and automatically switch back to SVG mode when going above 8? At least when running in a Notebook that shouldn't be a problem.

  3. gvwilson commented on Jul 3, 2024

    @gvwilson
    Contributor

    Hi - we are trying to tidy up the stale issues and PRs in Plotly's public repositories so that we can focus on things that are still important to our community. Since this one has been sitting for several years, I'm going to close it; if it is still a concern, please add a comment letting us know what recent version of our software you've checked it with so that I can reopen it and add it to our backlog. Thanks for your help - @gvwilson

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions