Jupyter notebook系列(5):主题的安装更换(主题颜色背景,字体字号大小,工具条可见,画图风格设置)

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 

image-20201109191253381

2.2 使用-t选项选择主题

最后一位的d应该是dark的缩写

最后一位的l应该是light的缩写

jt -t 主题名字
主题文件框示例代码框示例
chesterishimage-20201109191828996image-20201109192954296
grade3image-20201109191853532image-20201109193234889
gruvboxdimage-20201109192317486image-20201109193221318
gruvboxlimage-20201109192338877image-20201109193207115
monokaiimage-20201109192410888image-20201109193041631
oceans16image-20201109192438673image-20201109193151445
onedorkimage-20201109192512202image-20201109193132904
solarizeddimage-20201109192537060image-20201109193013357
solarizedlimage-20201109192613094

2.3 设置代码字体和字号

上面设置结束后字体并没有变化,这是因为我们并没有指定字体。

使用-f选项设置字体

jt -t chesterish -f roboto -fs 12   #设置主题为chesterish,字体为roboto,字体大小为12 

效果如下:

image-20201109193755317

2.4 设置工具条NAME等

我们发现字体发生了变化,舒服多了,但是原来菜单栏下方的工具条不见了,文件名也没有了。

显示工具条、log

使用-T命令使工具条可见,使用-N使Name和logo可见

jt -t onedork -f roboto -fs 12 -T -N

执行完后刷新页面,效果如下

image-20201109194203512

2.5 看一下其他选项

-tf 设置markdown的字体
-tfs 设置markdown字体大小
-dfs 设置Pandas DataFrame的字体大小
-ofs 设置输出的字体大小
-altp 关掉输入输出前面的数字
…其他详见官网

image-20201109200014900

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、参考文献

用SSH远程使用Jupyter – 霏霏在此

你可能并不知道这样定制炫酷的jupyter主题_计算机基础,职能岗位_超哥的杂货铺-商业新知

jupyter notebook中显示字体如何调整? - 知乎

Python Jupyter Notebook显示行号_AmyFlower6672的博客-CSDN博客

打造实用的Jupyter Notebook 扩展插件 - 知乎

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值