jupyter notebook / jupyter lab 深色主题下如何设置字体 及 如何设置绘图颜色

在安装了jupyter notebook / jupyter lab及其深色主题之后,需要进一步设置字体,和设置绘图的颜色。否则看起来界面会比较奇怪。
本文针对这几个问题作一些说明。

1. jupyter notebook 深色主题配置

cmdAnaconda Prompt中:

jupyter notebook 安装主题

pip install jupyterthemes

jupyter notebook 更新主题

pip install --upgrade jupyterthemes

查看可用主题

jt -l

暗色背景monokai设置 字体选择 fira 大小选 11 占屏比为90%,输出字段大小为11的设置方法

jt -t monokai -f fira -fs 11 -cellw 90% -ofs 11 -dfs 11 -T -N

参数解释:

  • f(字体)
  • fs(字体大小)
  • cellw(占屏比或宽度)
  • ofs(输出段的字号)
  • T(显示工具栏)
  • N(显示自己主机名)

还有ocean16背景的设置方法:

jt -t oceans16 -f fira -fs 11 -cellw 90% -ofs 11 -dfs 11 -T

1*. jupyter notebook插件安装

jupyter notebook的插件功能非常强大,所以在设置背景的同时,也需要进行插件安装。
首先安装nbextensions:

pip install jupyter_contrib_nbextensions
jupyter contrib nbextension install --user

然后安装 nbextensions_configurator:

pip install jupyter_nbextensions_configurator
jupyter nbextensions_configurator enable --user

在这种情况下,notebook主页上就会出现nbextensions的选项卡,可以在该选项卡下配置诸多的插件。

此处如果总是出现类似

Config option `template_path` not recognized by `LenvsLatexExporter`

的错误,则需要通过以下方式解决

conda install "nbconvert=5.6.1"

原因是nbconvert6.0.0版本以上的某些参数的名称发生了更改,与原先版本不兼容,需要将版本降低到5.6.1
解决方案的参考链接

2. jupyter notebook 绘图颜色设置

深色背景下,jupyter notebook采用matplotlib工具绘图时,坐标轴通常会因对比度的原因,非常难以识别。
在jupyterthemes下有jtplot包,可以选择一个绘图主题来进行绘制。

from jupyterthemes import jtplot
jtplot.style(theme='onedork') #选择一个绘图主题

参考链接-感谢前人栽树

3. jupyter lab 深色主题配置

关于深色主题的配置,可以参考本人以下文章(第6节):
Jupyterlab安装踩坑

jupyter lab还包含有字体插件,可以像其他IDE一样在相关的字体选项列表里对字体进行设置。

4. jupyter lab 绘图颜色设置

和jupyter notebook的处理方法一致。

  • 11
    点赞
  • 25
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值