LoginSignup
122
118

More than 3 years have passed since last update.

Jupyter Notebookの背景色やフォントをかっこよく変更する

Last updated at Posted at 2018-04-14

概要

image.png

白背景でちょっと疲れるjupyternotebookの背景色を変更する。

追記:好みの設定を追記。セル幅は-cellw 90% のような感じでブラウザの表示領域に対する比率で指定も可能で、なかなか使い勝手がよさそう。

jt -t onedork -f inconsolata -T -N -cellw 90% -tfs 11

環境

  • Windows10 64bit
  • Anaconda3-5.1.0-Windows-x86_64

背景色やフォントの変更

jupyterthemesのインストール

コマンドプロンプトでAnaconda3のディレクトリに移動し、pipでjupyterthemesをインストールする。

$ pip install jupyterthemes

以下コマンドでアップグレードできる

$ pip install --upgrade jupyterthemes

ちなみに現在利用可能なテーマは以下の通り

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

詳しくはこちら
jupyter-themes

テーマ・フォントの変更

$ jt -t onedork -f Ricty Diminished -T -N

-tでテーマをonedork、フォントはRicty Diminished(よく使われるプログラミング用のフォント)
Ricty Diminished
にする。
-T -N でツールバーやファイル名を表示できる。

※追記
https://qiita.com/damyarou/items/e1204d9f58bf86b4a4c9
で指摘されているように、-f Ricty Diminished が効かないようなので,フォントの変更について、 custom.css を直接変更する方法を追記します。

.jupyter\custom\custom.css (私の環境だとC:\Users\下にありました。)を編集モードで開き、

# ソースコードセル
div.CodeMirror,
div.CodeMirror pre {
 font-family: "Ricty Diminished";
 font-size: 13pt;
}
# 結果出力セル
div.output_subarea.output_text.output_stream.output_stdout,
div.output_subarea.output_text {
 font-family: "Ricty Diminished";
 font-size: 13pt;
}
div.output_area pre {
 font-family: "Ricty Diminished";
 font-size: 13pt;
}
# テキスト、MarkDownセル
div.text_cell,
div.text_cell_render pre,
div.text_cell_render {
 font-family: "Ricty Diminished";
 font-size: 13pt;
}

いろいろカスタマイズしたい場合は、cssをいじればいろいろできるはずです。

上のコマンドで設定したjupyternotebookはこんな感じ

jupyterthemes_sample.png

122
118
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
122
118