前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >对Jupyter Notebook实现个性化设置

对Jupyter Notebook实现个性化设置

作者头像
用户3577892
发布2020-06-12 16:16:05
1.2K0
发布2020-06-12 16:16:05
举报
文章被收录于专栏:数据科学CLUB数据科学CLUB

如何更换主题用pip进行装包设置主题jupyterthemes 的参数设置说明结果展示

作为数据分析的爱好者, jupyter notebook 在平时使用的频率很高,但经常觉得jupyter notebook 默认的风格不是很舒服,今天来分享下给 jupyter notebook 个性化配置的方法。

如何更换主题

Jupyter Notebook 的默认主题是白色背景的,如果想使用monokai主题怎么办呢?偶然发现Github有一位叫Kyle Dunovan的科学家已解决了这个问题,本次,用到的库为 jupyterthemes ,这个第三方库有多个主题可以更换,并且还可以更换字体类型以及大小等,看完这篇文章你会慢慢感受她的魅力。

jupyterthemes 的 github 地址如下:https://github.com/dunovank/jupyter-themes

用pip进行装包

自己安装的时候翻了墙,如果不翻墙速度很慢。

! pip install jupyterthemes

没有梯子的小伙伴可以改用豆瓣的 python 库来源,安装的代码如下:

!pip install -i https://pypi.doubanio.com/simple/ jupyterthemes

设置主题

成功安装了 jupyterthemes ,接下来,可以来设置自己喜欢的主题。在命令提示符下输入下面的代码来查看有哪些主题可以选择。

!jt -l
Available Themes: 
   chesterish
   grade3
   gruvboxd
   gruvboxl
   monokai
   oceans16
   onedork
   solarizedd
   solarizedl

设置主题的代码如下:

!jt -t monokai

注意设置好主题需要重新进入jupyter才可以看到效果

使用如下代码恢复到默认主题:

!jt -r

jupyterthemes 的参数设置说明

更多参数信息见https://github.com/dunovank/jupyter-themes

cl

options arg

default

Usage help

-h

--

List Themes

-l

--

Theme Name to Install

-t

--

Code Font

-f

--

Code Font-Size

-fs

11

Notebook Font

-nf

--

Notebook Font Size

-nfs

13

Text/MD Cell Font

-tf

--

Text/MD Cell Fontsize

-tfs

13

Pandas DF Fontsize

-dfs

9

Output Area Fontsize

-ofs

8.5

Mathjax Fontsize (%)

-mathfs

100

Intro Page Margins

-m

auto

Cell Width

-cellow

980

Line Height

-lineh

170

Cursor Width

-cursw

2

Cursor Color

-cursc

--

Alt Prompt Layout

-altp

--

Alt Markdown BG Color

-altmd

--

Alt Prompt Layout

-altp

--

Alt Markdown BG Color

-altmd

--

Alt Output BG Color

-altout

--

Style Vim NBExt*

-vim

--

Toolbar Visible

-T

--

Name & Logo Visible

-N

--

Kernel Logo Visible

-kl

--

Reset Default Theme

-r

--

Force Default Fonts

-dfonts

--

我自己设置参数的喜好:

 !jt -t monokai -f roboto -nf opensans -tf opensans -tfs   -N -T -kl -vim -cellw % -dfs  -ofs 
!jt -h
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

结果展示

结果展示

本文参与 腾讯云自媒体分享计划,分享自微信公众号。
原始发表:2020-02-10,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 数据科学CLUB 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 如何更换主题
    • 用pip进行装包
      • 设置主题
        • jupyterthemes 的参数设置说明
        • 结果展示
        领券
        问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档