Certain packages I am using create images that have black text. Unfortunately, my Jupyter theme is dark so this text is hard to read. The packages do not have parameters to change the font color easily. I would rather not change my jupyter theme, but ideally change the background color of a single jupyter cell's output. There was a similar question to change the color of the cells itself (How to change the background color of a single cell in a jupyter notebook / jupyterlab?), but I would like to change the output background color.
Asked
Active
Viewed 1,544 times
4
-
Would you be able to provide an example showing a simple plot for the plotting package you use? – krassowski Apr 07 '21 at 12:31
-
@krassowski Just uploaded an example image! – Arun Apr 13 '21 at 01:36
-
Thanks! Tracking in https://github.com/jupyterlab/jupyterlab/issues/10242. – krassowski May 14 '21 at 10:08
-
The below answer worked for me. https://stackoverflow.com/a/69766250/12784883 – Ysk196 Feb 11 '22 at 09:32
1 Answers
0
After a discussion on GitHub we narrowed down the same issue but reported by another user due to outdated version of ipykernel. To fix this, upgrade your ipykernel version and make sure it is newer than 4.9:
pip install -U ipykernel
# conda update ipykernel # if you use conda
If you cannot upgrade for some reason, you could use a workaround of manually changing style:
import matplotlib.pyplot as plt
plt.style.use('dark_background')
to get a consistent dark background, or use one of:
plt.style.use('seaborn')
or
plt.style.use('ggplot')
to get a consistent dark background. This is because scanpy uses matplotlib to render the figures so you should be able to just tweak matplotlib rendering settings to your liking with matplotlib APIs. For more on matplotlib styles see the documentation here.

krassowski
- 13,598
- 4
- 60
- 92