Skip to content Skip to sidebar Skip to footer

How To Edit A Jupyterlab Theme

I'd like to edit the JupyterLab Dark Theme, so that axis labels on inline plots can be clearly read. Example of the problem: To remedy this problem I'd like to change the backgrou

Solution 1:

To edit JupypterLab themes you need to make changes to the file variables.css which is located in jupyterlab/packages/[THEME NAME]/style/

You can inspect the element of the JupyterLab that you'd like to change to find out its class. I used Chrome DevTools ctrl+shift+i and click on various div classes until I found the one I wanted to alter.

Once you have the name of the div class you'd like to customize, add the changes to the variables.css file. Here's what I changed and the result.

.jp-RenderedImage {
  background-color: #A4A4A4
}

Change background of figures to grey to allow axis to be read

You can use this gist (where the code in the first cell comes from) created by one of the JupyterLab contributors to experiment with changes you made to the variables.css file.

Solution 2:

It looks like the example you show is because the plot's facecolor is transparent. I noticed this happened for my plots too when I switched to Jupyter's Dark Theme.

Here are two references for updating this Jupyter configuration:

  1. Enable white frames on matplotlib figure/ Disable transparent frames
  2. https://ipython.readthedocs.io/en/stable/config/intro.html

In summary, I opened the ~/.ipython/profile_default directory and created a new ipython_config.py file (because it wasn't already there)

cd ~/.ipython/profile_default/
vi ipython_config.py

In that file, I added the lines

c = get_config()
c.InlineBackend.print_figure_kwargs={'facecolor' : "w"}

Post a Comment for "How To Edit A Jupyterlab Theme"