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
参看文章
谢谢观看!