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()
インストール
# 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時にはチェインケースは利用できないのでスネークケースになっています。
Metadata
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)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| japanize-matplotlib-1.1.3.tar.gz | 4.1 MB | Without provenance | Details for japanize-matplotlib-1.1.3.tar.gz |
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
|
Security for japanize-matplotlib 1.1.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.