the way to make jupyter output cell has a dark background in vscode

发布时间 2023-05-24 23:42:20作者: yusisc

the issue to be fixed

As shown in the picture, jupyter output cell has a bright background, even it's ask to use dark background.
image

the way to go

import matplotlib.pyplot as plt
import numpy as np
from IPython.display import HTML

#############################    matplot setting up    ############################
%matplotlib widget
plt.style.use('dark_background')
HTML('''
<style>
    .jupyter-matplotlib {background-color: #003030;}
    .widget-label, .jupyter-matplotlib-header{color: #b0b0b0;}
    .jupyter-button {background-color: #333;color: #b0b0b0;}
    .cell-output-ipywidget-background {background-color: transparent !important;}
    .cell-output-ipywidget-background pre {color: white !important;}
</style>
''')

fig = plt.figure("fig0")
plt.clf()
plt.plot(np.arange(11))
plt.show()

image

reference

python - VS Code Jupyter notebook dark theme for interactive elements - Stack Overflow
https://stackoverflow.com/questions/75429196/vs-code-jupyter-notebook-dark-theme-for-interactive-elements

Add support for theming of IPyWidgets · Issue #7161 · microsoft/vscode-jupyter
https://github.com/microsoft/vscode-jupyter/issues/7161