Vscode-jupyter: White background on graphs

Created on 15 Oct 2019  路  5Comments  路  Source: microsoft/vscode-jupyter

Feature: Notebook Editor, Interactive Window, Python Editor cells

Description

Is there a way to implement white backgound in the plots even when using dark theme like in Jupyter Lab? When I am using a dark theme on vscode I cannot see what is in the graph's axis.

Example:
Jupyter Lab: https://i.ibb.co/bNXZwhy/1-jupyter.png
VsCode: https://i.ibb.co/bHQW506/2-jupyter.png

Most helpful comment

We need to add a setting to allow the user to decide whether we honor the theme for graphs. By default they should always render to a white background and not apply matplotlib themes.

All 5 comments

Did you change your theme after already running a cell? This should change the theming for the plots automatically. Unless of course you're changing the matplotlib theme yourself.

Hey gabriel19913. So with matplotlib you can set default styles with the style customization like so.
https://matplotlib.org/3.1.1/api/style_api.html
For our code when we detect dark themes by default we run matplotlib.style.use('dark_background').
However we also provide a setting in VSCode settings Python->Data Science->Run Startup Commands. This allows you to specify a set of custom commands to run at startup. Since these run after our theme settings you could run matplotlib.style.use('your style here') to set it back to light. Then this command would be run whenever you start up the interactive window or notebook editor. Does this work for you? I think 'classic' is just the default light theme.

Past that we also have a Ignore Vscode Theme setting, but that makes the entire window default light themed, so that doesn't sound like the option that you want.

It should be noted, after changing your theme, you currently need to restart the server (or close the notebook) and rerun the cell to get plots to show up correctly.

Meaning we will render them with a dark background as Ian describes, but only after rerendering. We don't reformat the existing output to be dark.

thanks for the advices @rchiodo and @IanMatthewHuff, I don't know what I am doing wrong, but this doesn't seem to work for me.
Like @IanMatthewHuff said I tried Python->Data Science->Run Startup Commands so I did this https://i.ibb.co/mhm7GVh/3-jupyter.png.
However now the plots are with a black backgroung:
https://i.ibb.co/x5sNFN2/4-jupyter.png
If I use the command matplotlib.style.use('default') in some cell it works, so I think I will with that for now.
Thanks for helping me.

We need to add a setting to allow the user to decide whether we honor the theme for graphs. By default they should always render to a white background and not apply matplotlib themes.

Was this page helpful?
0 / 5 - 0 ratings