my vscode jupyter configuration

my jupyter packages

from IPython.display import display, HTML
from matplotlib import cm, projections
from mpl_toolkits.mplot3d import Axes3D
from pathlib import Path
from pprint import pprint
import clipboard
import concurrent.futures
import cv2
import math
import matplotlib.pyplot as plt
import numpy as np
import os
import pandas as pd
import pickle
import PIL
import platform
import pprint
import re
import sys
import time

# import tensorflow as tf
# import torch
# from torch import Tensor

############################# section 1. pandas setting up. this should be located before section 2.
pd.set_option("display.max_columns", None)
# pd.set_option("display.max_rows", None)
############################# section 2. 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>
''')

vscode using existing jupyter server

step 0: start a local jupyter server

@REM start_jupyter_server.bat
jupyter notebook --no-browser --port=8888 --NotebookApp.token="aaa"
@REM https://127.0.0.1:8888/?token=aaa
@REM http://127.0.0.1:8888/?token=aaa

image

dark matplotlib output

Make Matplotlib widget background color match dark theme in Visual Studio Code
image
(Make sure Visual Studio Code is closed.)

  1. Open file explorer, go to: C:\Users\<your_username_here>\.vscode\extensions\ms-toolsai.jupyter-<(THE VERSION NUMBER MAY VARY)2022.4.1021342353>\out\webviews\webview-side\ipywidgetsRenderer
  2. Open the ipywidgetsRenderer.js file (using Notepad++ or Notepad or even Visual Studio Code) before letting any Jupyter stuff run
  3. Wherever you see cell-output-ipywidget-background followed by background: white, replace white with black.

from

Make Matplotlib widget background color match dark theme in Visual Studio Code - Stack Overflow
https://stackoverflow.com/questions/71206490/make-matplotlib-widget-background-color-match-dark-theme-in-visual-studio-code

posted on 2023-03-10 00:51  yusisc  阅读(35)  评论(0编辑  收藏  举报

导航