Skip to main content

PyPI version

japanize-matplotlib

matplotlib を日本語表示に対応させます

利用方法

matplotlibをimportした後、japanize_matplotlibをimportします。

import matplotlib.pyplot as plt
import japanize_matplotlib

plt.plot([1, 2, 3, 4])
plt.xlabel('簡単なグラフ')
plt.show()

demo

インストール

# pipenvで
pipenv install japanize-matplotlib

# またはpipで
pip install japanize-matplotlib

利用フォント

IPAフォントのIPAexゴシック(Ver.003.01)を利用しています。 利用にあたってはIPAフォントライセンスv1.0に同意してください。

FAQ

import japanize_matplotlib したのに日本語表示になりません #1

import japanize_matplotlib してから matplotlib でグラフを描画するまでにフォントの設定が変わる処理が入っていると、日本語表示がなされない可能性があります。

例えば、seaborn を利用している場合であれば sns.set() などで描画フォントが seaborn のデフォルトに上書きされ、日本語表示がされなくなります。

sns.set(font="IPAexGothic") のように利用フォントに IPAexGothic を設定するか、フォント上書き後に japanize_matplotlib.japanize() を利用するなどで日本語表示できるはずです。

import のみして利用されないコードなのでフォーマッターに消されてしまいます

リンターなどの警告が気になる・コードを消される方向けに japanize_matplotlib.japanize() メソッドの実行でも import 時と同じくフォントを設定できるようになっています。 無意味な実行になりますが、時と場合に応じて実行してください。

もしくはリンターごとに無視させる設定をすることで対応できるはずです。# noqa などで設定してください。

なぜインストール時は japanize-matplotlib で import 時は japanize_matplotlib なのですか?

チェインケースが読みやすく好きだからです。import時にはチェインケースは利用できないのでスネークケースになっています。

Release files for japanize-matplotlib 1.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for japanize-matplotlib 1.1.3
File Size Uploaded
japanize-matplotlib-1.1.3.tar.gz 4.1 MB Details

Release files / japanize-matplotlib-1.1.3.tar.gz

Download URL japanize-matplotlib-1.1.3.tar.gz
Size 4.1 MB
Tags Source
SHA-256 checksum
How to use checksums
e89e7d9e109820962650e59a130403b59b33915fde3871a265a5891d9bf5e079
BLAKE2b-256 checksum
How to use checksums
aa8508a4b7fe8987582d99d9bb7ad0ff1ec75439359a7f9690a0dbf2dbf98b15
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/46.1.3 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.6.5

Release history Release notifications | RSS feed

This release

1.1.3 This release

1 release file

1.1.2

1 release file

1.1.1

1 release file

1.1.0

1 release file

1.0.5

1 release file

1.0.4

1 release file

1.0.3

1 release file

1.0.2

1 release file

1.0.1

1 release file

1.0.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page