question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Python interactive window drops fps when creating many plots - SVG rendering is slow

See original GitHub issue

Not sure how hard it is to do anything about this but I noticed that if the Python interactive window contains lots of plots already (above maybe 30), adding new ones brings the frame rate down quite significantly. Above around 60 plots, it’s at less than 1 fps and makes all of VS Code become unresponsive. Once the plots are done, VS Code (including the interactive window) returns to normal.

python-interactive-many-plots-low-fps

Here’s some example code to reproduce the issue.

#%%
import matplotlib.pyplot as plt
import numpy as np

for i in range(100):
    plt.plot()
    N = 50
    x = np.random.rand(N)
    y = np.random.rand(N)
    colors = np.random.rand(N)
    area = (30 * np.random.rand(N)) ** 2  # 0 to 15 point radii
    plt.title(f"plot #{i + 1}")
    plt.scatter(x, y, s=area, c=colors, alpha=0.5)
    plt.show()

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:13 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
rchiodocommented, Jul 29, 2019

@DonJayamanne yes we want to do that too. Something like this looks promising: https://github.com/twobin/react-lazyload

However, SVG is a lot slower than PNG. We can fix jupyter to generate both.

1reaction
rchiodocommented, Jul 29, 2019

@DavidKutu my fix for microsoft/vscode-jupyter#3233 should fix this too.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Python interactive window drops fps when creating many plots ...
Possible solution - Generate PNGs along with the SVG, but only display the PNG in the history window. When the plot viewer opens,...
Read more >
why is plotting with Matplotlib so slow? - Stack Overflow
First off, (though this won't change the performance at all) consider cleaning up your code, similar to this: import matplotlib.pyplot as ...
Read more >
Improving SVG Runtime Performance - CodePen
Receiving and decoding data from the network takes CPU. The less of that, the more cycles left over for rendering. Plus, parse time...
Read more >
VisPy: Harnessing The GPU For Fast, High-Level ... - HAL-Inria
VisPy leverages the GPU to provide fast, interactive, and beautiful visualizations in a high-level API. Here we introduce the main features, ...
Read more >
VisPy: Harnessing The GPU For Fast, High-Level Visualization
VisPy lever- ages the GPU to provide fast, interactive, and beautiful visualizations in a high- level API. Here we introduce the main features,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found