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.

White background fills entire output cell for Matplotlib plots

See original GitHub issue

When I make a simple matplotlib plot, there is a white background covering the entire output cell area, which is pretty jarring in dark themes. I would expect it to only be white in the area immediately behind the figure. Also, I’m not sure why there is a small dark cutout in the lower right corner of the white background.

vscodejupyter

I’m guessing that it’s built this way because by default, the figure background is transparent. However, even if the plot image was partially transparent, I would not expect that to affect any parts of the screen beside the image itself, so this might be undesirable behavior.

Steps to reproduce:

  1. Create new blank notebook
  2. Enter code in cell:
import matplotlib.pyplot as plt
plt.figure()
plt.plot([1,2], [1,2])
plt.show()
  1. Run cell

Environment data

  • VS Code version: 1.61.0-insider
  • Jupyter Extension version: v2021.9.1001208778
  • Python Extension version: v2021.10.1210725981-dev
  • OS: Windows 10
  • Python 3.9.7
  • Type of virtual environment used: none
  • Jupyter server running: Local
  • No other extensions running besides Python + Jupyter

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:14 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
IanMatthewHuffcommented, Jan 26, 2022

@charlieh108 Looks like you might be missing the Jupyter renderers extension. VS Code separates execution from display so different extensions can provide different output renderings. The Jupyter renderers extension is supposed to install with the main Jupyter extension, but it looks like you are missing it. Try installing that, it should provide the right views: image image

You can see in my second image that it’s using the renderer from that extension.

1reaction
songololocommented, May 15, 2022

I don’t know what exactly it does, but there is a vscode setting which may or may not help in this instance:

 "jupyter.themeMatplotlibPlots": true,
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Set Plot Background Color in Matplotlib?
From the below figure one can infer that a plot consists of X-axis, Y-axis, plot title and the axes. By default, the color...
Read more >
How to set opacity of background colour of graph with ...
If you just want the entire background for both the figure and the axes to be transparent, you can simply specify transparent=True when...
Read more >
Dark background style sheet
This example demonstrates the "dark_background" style, which uses white for elements that are typically black (text, borders, etc). Note that not all plot...
Read more >
Cell output and plot background colors in DataSpell ...
However, I would like my plots to have white backgrounds. Changing the settings through matplotlib does not seem to work. I've searched ...
Read more >
4. Visualization with Matplotlib - Python Data Science ...
In visualization of data and results, showing these errors effectively can make a plot convey much more complete information. Basic Errorbars. A basic...
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