Jupyter notebook 系列
Jupyter notebook系列(1):安装与使用(安装,虚拟环境的联接使用,windows远程连接linux的jupyter)
Jupyter notebook系列(2):使用技巧(快捷键,多行输出,多光标操作,Unix系统命令的使用,查看输入输出历史,保存记录点与分享,抑制文末输出,图片输出,多环境kernel切换)
Jupyter notebook系列(3):魔法函数(查询,运行外部程序,计时,加载文件,变量管理调试,shell交互,图片的显示,查询环境变量,显示运行内核函数,kernel切换)
Jupyter notebook系列(4):插件的安装使用(代码折叠,添加目录,变量监控,代码格式化,运行时间统计,自动补全,自动保存,运行结束提醒)
Jupyter notebook系列(5):主题的安装更换(主题颜色背景,字体字号大小,工具条可见,画图风格设置)
Jupyter notebook系列(6):更高级的配置Mark(显示行号,更改工作路径,使用sudo权限)
文章目录
0、前言
Jupyter的主题是白色的比较伤眼睛另外字体也不好看。接下来主要修改windows默认的jupyter主题。
1、主题安装
5.1 使用最基本简便的pip,安装jupyterthemes
pip install jupyterthemes
5.2 更新到最新版本的jupyterthemes
pip install --upgrade jupytertheme
2、查看主题,选择主题,和一些主题参数配置(字体,字号等等)
不想细看的可以直接调到第三章看一下我的设置就可以啦
2.1 查看可用的jupytertheme主题
jt -l
2.2 使用-t选项选择主题
最后一位的d应该是dark的缩写
最后一位的l应该是light的缩写
jt -t 主题名字
主题 | 文件框示例 | 代码框示例 |
---|---|---|
chesterish | ||
grade3 | ||
gruvboxd | ||
gruvboxl | ||
monokai | ||
oceans16 | ||
onedork | ||
solarizedd | ||
solarizedl |
2.3 设置代码字体和字号
上面设置结束后字体并没有变化,这是因为我们并没有指定字体。
使用-f选项设置字体
jt -t chesterish -f roboto -fs 12 #设置主题为chesterish,字体为roboto,字体大小为12
效果如下:
2.4 设置工具条NAME等
我们发现字体发生了变化,舒服多了,但是原来菜单栏下方的工具条不见了,文件名也没有了。
显示工具条、log
使用-T命令使工具条可见,使用-N使Name和logo可见
jt -t onedork -f roboto -fs 12 -T -N
执行完后刷新页面,效果如下
2.5 看一下其他选项
-tf 设置markdown的字体
-tfs 设置markdown字体大小
-dfs 设置Pandas DataFrame的字体大小
-ofs 设置输出的字体大小
-altp 关掉输入输出前面的数字
…其他详见官网
usage: jt [-h] [-l] [-t THEME] [-f MONOFONT] [-fs MONOSIZE] [-nf NBFONT]
[-nfs NBFONTSIZE] [-tf TCFONT] [-tfs TCFONTSIZE] [-dfs DFFONTSIZE]
[-ofs OUTFONTSIZE] [-mathfs MATHFONTSIZE] [-m MARGINS]
[-cursw CURSORWIDTH] [-cursc CURSORCOLOR] [-cellw CELLWIDTH]
[-lineh LINEHEIGHT] [-altp] [-altmd] [-altout] [-P] [-T] [-N] [-kl]
[-vim] [-r] [-dfonts]
optional arguments:
-h, --help show this help message and exit
-l, --list list available themes
-t THEME, --theme THEME
theme name to install
-f MONOFONT, --monofont MONOFONT
monospace code font
-fs MONOSIZE, --monosize MONOSIZE
code font-size
-nf NBFONT, --nbfont NBFONT
notebook font
-nfs NBFONTSIZE, --nbfontsize NBFONTSIZE
notebook fontsize
-tf TCFONT, --tcfont TCFONT
txtcell font
-tfs TCFONTSIZE, --tcfontsize TCFONTSIZE
txtcell fontsize
-dfs DFFONTSIZE, --dffontsize DFFONTSIZE
pandas dataframe fontsize
-ofs OUTFONTSIZE, --outfontsize OUTFONTSIZE
output area fontsize
-mathfs MATHFONTSIZE, --mathfontsize MATHFONTSIZE
mathjax fontsize (in %)
-m MARGINS, --margins MARGINS
fix margins of main intro page
-cursw CURSORWIDTH, --cursorwidth CURSORWIDTH
set cursorwidth (px)
-cursc CURSORCOLOR, --cursorcolor CURSORCOLOR
cursor color (r, b, g, p)
-cellw CELLWIDTH, --cellwidth CELLWIDTH
set cell width (px or %)
-lineh LINEHEIGHT, --lineheight LINEHEIGHT
code/text line-height (%)
-altp, --altprompt alt input prompt style
-altmd, --altmarkdown
alt markdown cell style
-altout, --altoutput set output bg color to notebook bg
-P, --hideprompt hide cell input prompt
-T, --toolbar make toolbar visible
-N, --nbname nb name/logo visible
-kl, --kernellogo kernel logo visible
-vim, --vimext toggle styles for vim
-r, --reset reset to default theme
-dfonts, --defaultfonts
force fonts to browser default
3 分享一个我的设置
jt -t oceans16 -f roboto -fs 13 -cellw 90% -ofs 11 -dfs 11 -T -N
4 恢复原主题
如果你不想使用现在的主题,可以使用-r选项进行重置
jt -r
5 画图风格的设置
我们可以使用jtplot设置matplotlib的rcParams字典属性,以便图形风格能够适配我们选择的主题。
from jupyterthemes import jtplot
jtplot.style(theme='onedork') #选择一个绘图主题
#设置绘图的额风格,如坐标轴字体,网格样式等
jtplot.style(context='talk', fscale=1.4, spines=False, gridlines='--')
#设置坐标轴,网格的开闭,图形大小等
jtplot.style(ticks=True, grid=False, figsize=(6, 4.5))
#重置设置
jtplot.reset()
LAST、参考文献
你可能并不知道这样定制炫酷的jupyter主题_计算机基础,职能岗位_超哥的杂货铺-商业新知
jupyter notebook中显示字体如何调整? - 知乎