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.

the background color of inline figure out of control

See original GitHub issue

I have read https://github.com/microsoft/vscode-jupyter/issues/2904. The background color is still strange with different conditions. I’m sorry for creating a new issue. In the non-interactive mode (%matplotlib inline), I must type fig to show the previous picture again in the other cells. But the label of axis is hard to see because of transparent background. unexpected case: what happened? image normal case: everything ok image

Environment data

  • VS Code version: 1.67.2

  • Jupyter Extension version (available under the Extensions sidebar): v2022.5.1001311010

  • Python Extension version (available under the Extensions sidebar): v2022.7.11401005

  • OS (Windows | Mac | Linux distro) and version: Ubuntu 20.04.4 LTS x86_64

  • Python and/or Anaconda version: conda version : 4.12.0 & python 3.10.4

  • Type of virtual environment used (N/A | venv | virtualenv | conda | …): conda

  • Jupyter server running: Local

Expected behaviour

image

Actual behaviour

image

Steps to reproduce:

image

%matplotlib inline
from matplotlib import pyplot as plt
fig,ax = plt.subplots(figsize=[10,3])
fig

image

Logs

Output for Jupyter in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Jupyter)

Visual Studio Code (1.67.2, undefined, desktop)
Jupyter Extension Version: 2022.5.1001311010.
Python Extension Version: 2022.7.11401005.
Workspace folder /home/wxz/Program/python/toolkit
info 15:40:24.54: ZMQ install verified.
User belongs to experiment group 'jupyterTestcf'
User belongs to experiment group 'jupyterEnhancedDataViewer'
info 15:40:24.237: Old kernelSpecs (created by Jupyter extension) stored in directory /home/wxz/.local/share/jupyter/kernels/__old_vscode_kernelspecs
info 15:40:24.251: Experiment status for python is {"enabled":true,"optInto":[],"optOutFrom":[]}
info 15:40:24.363: Starting Jupyter Session id = .jvsc74a57bd07d83130797eb8105b0d72229ce3afe26e11a7f3d1d2ef83445961f78e12cdb01./home/wxz/Program/miniconda3/envs/seismic/python./home/wxz/Program/miniconda3/envs/seismic/python.-m#ipykernel_launcher for /home/wxz/Program/python/toolkit/plot/test.ipynb (disableUI=true)
info 15:40:24.365: Creating raw notebook for /home/wxz/Program/python/toolkit/plot/test.ipynb
info 15:40:24.365: Computing working directory /home/wxz/Program/python/toolkit/plot/test.ipynb
info 15:40:24.427: Starting raw kernel seismic (Python 3.10.4) for interpreter /home/wxz/Program/miniconda3/envs/seismic/bin/python
info 15:40:24.431: Kernel launching with ports 9000,9001,9002,9003,9004. Start port is 9000
info 15:40:24.519: Preferred Remote kernel for /home/wxz/Program/python/toolkit/plot/test.ipynb is undefined
info 15:40:24.519: Find preferred kernel for /home/wxz/Program/python/toolkit/plot/test.ipynb with metadata {"kernelspec":{"display_name":"Python 3.10.4 ('seismic')","language":"python","name":"python3"},"language_info":{"codemirror_mode":{"name":"ipython","version":3},"file_extension":".py","mimetype":"text/x-python","name":"python","nbconvert_exporter":"python","pygments_lexer":"ipython3","version":"3.10.4"},"orig_nbformat":4,"vscode":{"interpreter":{"hash":"7d83130797eb8105b0d72229ce3afe26e11a7f3d1d2ef83445961f78e12cdb01"}}} & preferred interpreter /home/wxz/Program/miniconda3/envs/seismic/bin/python
info 15:40:24.523: Preferred Remote kernel for /home/wxz/Program/python/toolkit/plot/test.ipynb is undefined
info 15:40:24.523: Preferred kernel .jvsc74a57bd07d83130797eb8105b0d72229ce3afe26e11a7f3d1d2ef83445961f78e12cdb01./home/wxz/Program/miniconda3/envs/seismic/python./home/wxz/Program/miniconda3/envs/seismic/python.-m#ipykernel_launcher is exact match
info 15:40:24.523: PreferredConnection: .jvsc74a57bd07d83130797eb8105b0d72229ce3afe26e11a7f3d1d2ef83445961f78e12cdb01./home/wxz/Program/miniconda3/envs/seismic/python./home/wxz/Program/miniconda3/envs/seismic/python.-m#ipykernel_launcher found for NotebookDocument: /home/wxz/Program/python/toolkit/plot/test.ipynb
info 15:40:24.523: TargetController found ID: .jvsc74a57bd07d83130797eb8105b0d72229ce3afe26e11a7f3d1d2ef83445961f78e12cdb01./home/wxz/Program/miniconda3/envs/seismic/python./home/wxz/Program/miniconda3/envs/seismic/python.-m#ipykernel_launcher for document /home/wxz/Program/python/toolkit/plot/test.ipynb
info 15:40:24.833: Process Execution: > ~/Program/miniconda3/envs/seismic/bin/python -m pip list
> ~/Program/miniconda3/envs/seismic/bin/python -m pip list
info 15:40:24.846: Process Execution: > ~/Program/miniconda3/envs/seismic/bin/python -c "import ipykernel; print(ipykernel.__version__); print("5dc3a68c-e34e-4080-9c3e-2a532b2ccb4d"); print(ipykernel.__file__)"
> ~/Program/miniconda3/envs/seismic/bin/python -c "import ipykernel; print(ipykernel.__version__); print("5dc3a68c-e34e-4080-9c3e-2a532b2ccb4d"); print(ipykernel.__file__)"
info 15:40:24.848: Adding env Variable PYTHONNOUSERSITE to /home/wxz/Program/miniconda3/envs/seismic/bin/python
info 15:40:24.862: Process Execution: > ~/Program/miniconda3/envs/seismic/bin/python -m ipykernel_launcher --ip=127.0.0.1 --stdin=9003 --control=9001 --hb=9000 --Session.signature_scheme="hmac-sha256" --Session.key=b"c259473e-1551-4ecb-9653-510a6abc7686" --shell=9002 --transport="tcp" --iopub=9004 --f=/home/wxz/.local/share/jupyter/runtime/kernel-24810617NXGVeIwrNIi.json
> ~/Program/miniconda3/envs/seismic/bin/python -m ipykernel_launcher --ip=127.0.0.1 --stdin=9003 --control=9001 --hb=9000 --Session.signature_scheme="hmac-sha256" --Session.key=b"c259473e-1551-4ecb-9653-510a6abc7686" --shell=9002 --transport="tcp" --iopub=9004 --f=/home/wxz/.local/share/jupyter/runtime/kernel-24810617NXGVeIwrNIi.json
info 15:40:24.862: Process Execution: cwd: ~/Program/python/toolkit/plot
cwd: ~/Program/python/toolkit/plot
info 15:40:24.898: Registering dummy command feature
info 15:40:24.999: ipykernel version 6.13.0 for /home/wxz/Program/miniconda3/envs/seismic/bin/python
info 15:40:24.999: ipykernel location ~/Program/miniconda3/envs/seismic/lib/python3.10/site-packages/ipykernel/__init__.py for /home/wxz/Program/miniconda3/envs/seismic/bin/python
warn 15:40:25.350: StdErr from Kernel Process /home/wxz/Program/miniconda3/envs/seismic/lib/python3.10/site-packages/traitlets/traitlets.py:2389: FutureWarning: Supporting extra quotes around strings is deprecated in traitlets 5.0. You can use 'hmac-sha256' instead of '"hmac-sha256"' if you require traitlets >=5.
  warn(
/home/wxz/Program/miniconda3/envs/seismic/lib/python3.10/site-packages/traitlets/traitlets.py:2343: FutureWarning: Supporting extra quotes around Bytes is deprecated in traitlets 5.0. Use 'c259473e-1551-4ecb-9653-510a6abc7686' instead of 'b"c259473e-1551-4ecb-9653-510a6abc7686"'.
  warn(

info 15:40:25.357: Kernel Output: NOTE: When using the `ipython kernel` entry point, Ctrl-C will not work.

To exit, you will have to explicitly quit this process, by either sending
"quit" from a client, or using Ctrl-\ in UNIX-like environments.

To read more about this, see https://github.com/ipython/ipython/issues/2049


To connect another client to this kernel, use:
    --existing kernel-24810617NXGVeIwrNIi.json

info 15:40:25.511: Started kernel seismic (Python 3.10.4), (Raw session started and connected)
info 15:40:25.512: Finished connecting 079787ab-3353-483b-9292-103200ab4d0c
info 15:40:25.683: Preferred Remote kernel for /home/wxz/Program/python/toolkit/plot/test.ipynb is undefined
info 15:40:25.683: Find preferred kernel for /home/wxz/Program/python/toolkit/plot/test.ipynb with metadata {"kernelspec":{"display_name":"Python 3.10.4 ('seismic')","language":"python","name":"python3"},"language_info":{"codemirror_mode":{"name":"ipython","version":3},"file_extension":".py","mimetype":"text/x-python","name":"python","nbconvert_exporter":"python","pygments_lexer":"ipython3","version":"3.10.4"},"orig_nbformat":4,"vscode":{"interpreter":{"hash":"7d83130797eb8105b0d72229ce3afe26e11a7f3d1d2ef83445961f78e12cdb01"}}} & preferred interpreter /home/wxz/Program/miniconda3/envs/seismic/bin/python
info 15:40:25.686: Preferred Remote kernel for /home/wxz/Program/python/toolkit/plot/test.ipynb is undefined
info 15:40:25.686: Preferred kernel .jvsc74a57bd07d83130797eb8105b0d72229ce3afe26e11a7f3d1d2ef83445961f78e12cdb01./home/wxz/Program/miniconda3/envs/seismic/python./home/wxz/Program/miniconda3/envs/seismic/python.-m#ipykernel_launcher is exact match
info 15:40:25.687: Preferred Remote kernel for /home/wxz/Program/python/toolkit/plot/test.ipynb is undefined
info 15:40:25.851: UpdateWorkingDirectoryAndPath in Kernel
info 15:40:25.851: Executing silently Code (idle) = import os\nimport sys\n%cd "/home/wxz/Program/python/toolkit/plot"\nif os.getcwd() not in sys.path:
info 15:40:26.6: Executing silently Code (completed) = import os\nimport sys\n%cd "/home/wxz/Program/python/toolkit/plot"\nif os.getcwd() not in sys.path:
info 15:40:26.6: Waiting for idle on (kernel): b1b63ded-2e8b-4179-a274-867c8b1b2369 -> idle
info 15:40:26.7: Finished waiting for idle on (kernel): b1b63ded-2e8b-4179-a274-867c8b1b2369 -> idle
info 15:40:37.876: Execute Cell 0 /home/wxz/Program/python/toolkit/plot/test.ipynb
info 15:40:37.877: Execute Cell 1 /home/wxz/Program/python/toolkit/plot/test.ipynb
info 15:40:37.877: Execute Cell 2 /home/wxz/Program/python/toolkit/plot/test.ipynb
info 15:40:37.877: Execute Cell 3 /home/wxz/Program/python/toolkit/plot/test.ipynb
info 15:40:38.404: Cell 0 executed with state Success
info 15:40:38.487: Cell 1 executed with state Success
info 15:40:38.574: Cell 2 executed with state Success
info 15:40:38.671: Cell 3 executed with state Success

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
rchiodocommented, May 23, 2022

Oh I had this setting enabled. With it disabled I can repro.

image

So that’s another workaround, turn on SVG output.

0reactions
DonJayamannecommented, Aug 22, 2022

I’m running into the exact same behaviour when using Jupyter lab. Basically the output generated by Matplotlib doesn’t contain the necessary metadata to tell the front end whether to use a white background or not.

"jupyter.themeMatplotlibPlots": false,

Using the above to generate SVG images is a work around, a work around for a problem that exists in Jupyter lab as well. Jupyter Notebooks don’t have this issue as it is always presented in white (not a black them).

Screen Shot 2022-08-22 at 11 49 12

Read more comments on GitHub >

github_iconTop Results From Across the Web

background-color - CSS: Cascading Style Sheets | MDN
The background-color CSS property sets the background color of an element.
Read more >
How to set background color in HTML? - Tutorialspoint
To set the background color in HTML, use the style attribute, with the CSS property background-color inside the body tag of the HTML...
Read more >
How to Add a Background-Color for the Text Width Instead of ...
The next step is to set the background-color on the <span> element. The inline element is as big as its content, and this...
Read more >
jQuery: How do I get an inline style (background-color) from ...
What I need is to grab the inline style that's applied and add that same rgb background-color and add it to another element...
Read more >
How to Add & Change Background Color in HTML
First, find the div in your HTML code and add a class to the opening tag. Adding a class to an element will...
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