1. 程式人生 > 其它 >更改Jupyter notebook主題

更改Jupyter notebook主題

jupyter notebook是一款寫程式碼的神奇,那麼如何在使用的過程中,修改主題呢?學習了github文件,總結如下:

一:安裝或更新jupyterthemes
# install jupyterthemes
pip install jupyterthemes

# upgrade to latest version
pip install --upgrade jupyterthemes
二:輸入相關命令
jt  [-h] [-l] [-t THEME] [-f MONOFONT] [-fs MONOSIZE] [-nf NBFONT]
    [-nfs NBFONTSIZE] [-tf TCFONT] [-tfs TCFONTSIZE] [-dfs DFFONTSIZE]
    [-m MARGINS] [-cursw CURSORWIDTH] [-cursc CURSORCOLOR] [-vim]
    [-cellw CELLWIDTH] [-lineh LINEHEIGHT] [-altp] [-altmd] [-altout]
    [-P] [-T] [-N] [-r] [-dfonts]
常用的命令引數解釋如下:
引數含義 引數名稱 預設值
主題列表 -l --
主題名稱 -t --
字型 -f --
字型大小 -fs 11
jupyter字型 -nf --
jupyter字型大小 nfs 13
Text/MD Cell Font -tf --
Text/MD Cell Fontsize -tfs 13
Pandas DF Fontsize -dfs 9
Cell Width -cellw 980
Line Height -lineh 170
... ... ...
更多引數含義參考jupyter notebook github文件
三、主題設定示例
# list available themes
# onedork | grade3 | oceans16 | chesterish | monokai | solarizedl | solarizedd
jt -l

# select theme...
jt -t chesterish

# restore default theme
# NOTE: Need to delete browser cache after running jt -r
# If this doesn't work, try starting a new notebook session.
jt -r

# toggle toolbar ON and notebook name ON
jt -t grade3 -T -N

# toggle kernel logo.  kernel logo is in same container as name
# toggled with -N.  That means that making the kernel logo visible is
# pointless without also making the name visible
jt -t grade3 -N -kl

# set code font to 'Roboto Mono' 12pt
# (see monospace font table below)
jt -t onedork -f roboto -fs 12

# set code font to Fira Mono, 11.5pt
# 3digit font-sizes get converted into float (115-->11.5)
# 2digit font-sizes > 25 get converted into float (85-->8.5)
jt -t solarizedd -f fira -fs 115

# set font/font-size of markdown (text cells) and notebook (interface)
# see sans-serif & serif font tables below
jt -t oceans16 -tf merriserif -tfs 10 -nf ptsans -nfs 13

# adjust cell width (% screen width) and line height
jt -t chesterish -cellw 90% -lineh 170

# or set the cell width in pixels by leaving off the '%' sign
jt -t solarizedl -cellw 860

# fix the container-margins on the intro page (defaults to 'auto')
jt -t monokai -m 200

# adjust cursor width (in px) and make cursor red
# options: b (blue), o (orange), r (red), p (purple), g (green), x (font color)
jt -t oceans16 -cursc r -cursw 5

# choose alternate prompt layout (narrower/no numbers)
jt -t grade3 -altp

# my two go-to styles
# dark
jt -t onedork -fs 95 -altp -tfs 11 -nfs 115 -cellw 88% -T
# light
jt -t grade3 -fs 95 -altp -tfs 11 -nfs 115 -cellw 88% -T
四、推薦的主題設定
jt -t chesterish -f fira -fs 17 -cellw 90% -ofs 15 -dfs 15 -T -T
jt -t grade3 -f fira -fs 17 -cellw 90% -ofs 15 -dfs 15 -T -T
jt -t gruvboxd -f fira -fs 17 -cellw 90% -ofs 15 -dfs 15 -T -T
jt -t gruvboxl -f fira -fs 17 -cellw 90% -ofs 15 -dfs 15 -T -T
jt -t monokai -f fira -fs 17 -cellw 90% -ofs 15 -dfs 15 -T -T
jt -t oceans16 -f fira -fs 17 -cellw 90% -ofs 15 -dfs 15 -T -T
jt -t onedork -f fira -fs 17 -cellw 90% -ofs 15 -dfs 15 -T -T
jt -t solarizedd -f fira -fs 17 -cellw 90% -ofs 15 -dfs 15 -T -T
jt -t solarizedl -f fira -fs 17 -cellw 90% -ofs 15 -dfs 15 -T -T
參看文章

https://www.cnblogs.com/shanger/p/12006161.html

謝謝觀看!