4
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

jupyter notebookを使い始めるための初期設定

Last updated at Posted at 2017-02-15

日本語フォントの設定

まず、システムにインストールされているフォントを列挙する。

import matplotlib.font_manager as fm
import pandas as pd
d = []
fonts = fm.findSystemFonts()
for f in fonts:
    font = fm.FontProperties(fname=f)
    try:
        d.append((f, font.get_name()))
    except:
        print("could not find: {0}".format(f))
df = pd.DataFrame(d, columns=['path', 'name'])
print(df)

その後、以下で設定

import matplotlib.font_manager
font = matplotlib.font_manager.FontProperties(fname='/usr/share/fonts/truetype/takao-gothic/TakaoGothic.ttf')
# or
font = matplotlib.font_manager.FontProperties(fname='/Library/Fonts/Arial Unicode.ttf')

使用する際には、fontpropertiesに先のフォントを指定する。

for i, w in enumerate(words):
    plt.annotate(w, xy = (xs[i], ys[i]), xytext = (3, 3), textcoords = 'offset points', ha = 'left', va = 'top', fontproperties=font, fontsize=10)

画像をインラインで表示するための設定+α

%matplotlib inline
# -*- coding: utf-8 -*-
from __future__ import print_function
...

表示される画像のサイズを大きくするための設定

figsizeに大きな数字を指定する

plt.figure(figsize=(8,6))
4
4
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
4
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?