使用jupyterthemes插件定制jupyter notebook界面
jupyter notebook界面是可以定制的,定制位置在:C:\anaconda\Lib\site-packages\notebook\static\custom
。
启动jupyter notebook之后,查看网页源代码,会发现网页中会自动加载custom.css和custom.js。
于是有人推出了jupyter-themes这款主题定制工具,这个工具使用上是存在一些界面bug的。
github地址:https://github.com/dunovank/jupyter-themes
一、安装
# install jupyterthemes
pip install jupyterthemes
# upgrade to latest version
pip install --upgrade jupyterthemes
二、基本用法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
三、github上的README教程
Description of Command Line options
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 | -cellw | 980 |
Line Height | -lineh | 170 |
Cursor Width | -cursw | 2 |
Cursor Color | -cursc | -- |
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 | -- |
Command Line Examples
# 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
Set Plotting Style (from within notebook)
jtplot.style()
makes changes to matplotlib's rcParams dictionary so that figure aesthetics match those of a chosen jupyterthemes style. In addition to setting the color scheme, jtplot.style()
allows you to control various figure properties (spines, grid, font scale, etc.) as well as the plotting "context" (borrowed from seaborn).
Note, these commands do not need to be re-run every time you generate a new plot, just once at the beginning of your notebook or whenever style changes are desired after that.
Pro-tip: Include the following two lines in ~/.ipython/profile_default/startup/startup.ipy
file to set plotting style automatically whenever you start a notebook:
# import jtplot submodule from jupyterthemes
from jupyterthemes import jtplot
# currently installed theme will be used to
# set plot style if no arguments provided
jtplot.style()
jtplot.style() Examples
# import jtplot module in notebook
from jupyterthemes import jtplot
# choose which theme to inherit plotting style from
# onedork | grade3 | oceans16 | chesterish | monokai | solarizedl | solarizedd
jtplot.style(theme='onedork')
# set "context" (paper, notebook, talk, poster)
# scale font-size of ticklabels, legend, etc.
# remove spines from x and y axes and make grid dashed
jtplot.style(context='talk', fscale=1.4, spines=False, gridlines='--')
# turn on X- and Y-axis tick marks (default=False)
# turn off the axis grid lines (default=True)
# and set the default figure size
jtplot.style(ticks=True, grid=False, figsize=(6, 4.5))
# reset default matplotlib rcParams
jtplot.reset()
Monospace Fonts (code cells)
-f arg | Monospace Font |
---|---|
anka | Anka/Coder |
anonymous | Anonymous Pro |
aurulent | Aurulent Sans Mono |
bitstream | Bitstream Vera Sans Mono |
bpmono | BPmono |
code | Code New Roman |
consolamono | Consolamono |
cousine | Cousine |
dejavu | DejaVu Sans Mono |
droidmono | Droid Sans Mono |
fira | Fira Mono |
firacode | Fira Code |
generic | Generic Mono |
hack | Hack |
hasklig | Hasklig |
inconsolata | Inconsolata-g |
inputmono | Input Mono |
iosevka | Iosevka |
liberation | Liberation Mono |
meslo | Meslo |
office | Office Code Pro |
oxygen | Oxygen Mono |
roboto | Roboto Mono |
saxmono | saxMono |
source | Source Code Pro |
sourcemed | Source Code Pro Medium |
ptmono | PT Mono |
ubuntu | Ubuntu Mono |
Sans-Serif Fonts
-nf/-tf arg | Sans-Serif Font |
---|---|
opensans | Open Sans |
droidsans | Droid Sans |
exosans | Exo_2 |
latosans | Lato |
ptsans | PT Sans |
robotosans | Roboto |
sourcesans | Source Sans Pro |
Serif Fonts
-nf/-tf arg | Serif Font |
---|---|
loraserif | Lora |
ptserif | PT Serif |
georgiaserif | Georgia |
cardoserif | Cardo |
crimsonserif | Crimson Text |
ebserif | EB Garamond |
merriserif | Merriweather |
neutonserif | Neuton |
goudyserif | Sorts Mill Goudy |
四、 深度定制
一般设置一下主题和字体就足够普通用户使用了,例如:
jt -t monokai -f consolamono -fs 15
如果还嫌瑕疵,那就需要自己去改前端了。
在~/.jupyter\custom
目录下有主题、CSS、字体等。
使用jupyterthemes插件定制jupyter notebook界面的更多相关文章
- python插件,pycharm基本用法,markdown文本编写,jupyter notebook的基本操作汇总
5.14自我总结 一.python插件插件相关技巧汇总 安装在cmd上运行 #比如安装 安装:wxpy模块(支持 Python 3.4-3.+ 以及 2.7 版本):pip3 install wxpy ...
- jupyter notebook的插件安装及文本格式修改
jupyter notebook的插件安装及文本格式修改 1.jupyter notebook拓展插件安装 启动jupyter notebook : 打开控制台输入命令 jupyter noteboo ...
- 使用Jupyter Notebook编写技术文档
1.jupyter Notebook的组成 这里它的组件及其工程构成,帮助大家更好的用好jupyter Notebook 组件 Jupyter Notebook结合了三个组件: 笔记本Web应用程序: ...
- Jupyter notebook入门
Jupyter notebook入门 [TOC] Jupyter notebook 是一种 Web 应用,能让用户将说明文本.数学方程.代码和可视化内容全部组合到一个易于共享的文档中. Jupyter ...
- jupyter notebook的安装与基本操作
0.前言 最近正在重温Python基础知识,为了方便练习敲代码,于是选择安装jupyter notebook作为代码编辑器. Project Jupyter exists to develop ope ...
- MAC安装python jupyter notebook
介绍: Jupyter Notebook(此前被称为 IPython notebook)是一个交互式笔记本,支持运行 40 多种编程语言. Jupyter Notebook 的本质是一个 Web 应用 ...
- 写给.NET开发者的Python教程(一):C# vs Python: 语言特性、Conda和Jupyter Notebook环境
承接上篇,本文会从语言特性.开发环境和必备工具来带领大家进入Python的世界. 语言特性 首先一起看下C#和Python在语言特性层面的对比,他们作为截然不同的两类面向对象高级语言,在语言层面上有何 ...
- Jupyter Notebook使用教程
关于安装我就不说了,可以参考知乎https://zhuanlan.zhihu.com/p/33105153(总结的很全面) 首先打开Jupyter Notebook后,新建notebook:点击右上角 ...
- jupyter notebook设置主题背景,字体和扩展插件
windows上安装Anaconda (IPython notebook) Anaconda是一个包与环境的管理器,一个Python发行版,以及一个超过1000多个开源包的集合.它是免费和易于安装的, ...
随机推荐
- 用css3和jQuery制作精美的表单
用css3和jQuery制作一个简单的精美表单 html代码如下: <span class="title">Mask Your Input Forms and Make ...
- IntelliJ IDEA windows与mac下常用快捷键
摘自: http://www.th7.cn/Program/java/201604/817219.shtml 1.找文件找代码找引用 shif双击在项目的所有目录查找 ctrl+f(mac下:comm ...
- Ubuntu环境变量解析
在Ubuntu中有如下几个文件可以设置环境变量 /etc/profile:在登录时,操作系统定制用户环境时使用的第一个文件,此文件为系统的每个用户设置环境信息,当用户第一次登录时,该文件被执行. /e ...
- Android -- ViewPager切换动画,PageTransformer
transformPage(View view, float position) view就是滑动中的那个view,position这里是float类型,是当前滑动状态的一个表示,比如当滑动到正全屏时 ...
- 梯度消失(vanishing gradient)与梯度爆炸(exploding gradient)问题
(1)梯度不稳定问题: 什么是梯度不稳定问题:深度神经网络中的梯度不稳定性,前面层中的梯度或会消失,或会爆炸. 原因:前面层上的梯度是来自于后面层上梯度的乘乘积.当存在过多的层次时,就出现了内在本质上 ...
- Mahout 安装配置
http://log.medcl.net/item/2011/02/mahout_install/ Apache Mahout是一个机器学习的框架,构建在hadoop上支持大规模数据集的处理,目前最新 ...
- 利用shell脚本批量提交网站404死链给百度
网站运营人员对于死链这个概念一定不陌生,网站的一些数据删除或页面改版等都容易制造死链,影响用户体验不说,过多的死链还会影响到网站的整体权重或排名. 百度站长平台提供的死链提交工具,可将网站存在的死链( ...
- Cognos11中Dashboard和HTML页面的简单集成
一.需求 之前很多第三方的程序都是通脱URL的形式可以和cognos Report进行集成,在我前几天的博文<Cognos11中通过URL访问report的设置>一篇中也提到了普通repo ...
- Android 模仿QQ风格的 UI
本文内容 环境 演示模仿QQ风格的界面 本文主要演示的是 UI,如何模仿 QQ 风格的界面.虽然这个 UI 跟现在的QQ空间有点差别,但是也能学到很多东西. 下载 Demo 环境 Windows 7 ...
- 获取oracle 随机数
http://www.cnblogs.com/lgzslf/archive/2008/11/29/1343685.html select substr(dbms_random.random,2,2) ...