japanize-matplotlib-modern
2025年最新版matplotlib を日本語表示に対応させます
利用方法
networkXで利用したいときに font_family="IPAexGothic" を指定します。
import networkx as nx
import matplotlib.pyplot as plt
import japanize_matplotlib_modern
G = nx.Graph()
G.add_node("あ")
G.add_node("い")
G.add_node("う")
G.add_node("え")
G.add_node("お")
G.add_edges_from([("あ", "お"), ("あ", "い"), ("え", "い"), ("え", "う"), ("あ", "う")])
#ここで描画時にフォントを指定します
nx.draw_networkx(G, font_family="IPAexGothic")
plt.show()
matplotlibをimportした後、japanize_matplotlib_modernをimportします。
import matplotlib.pyplot as plt
import japanize_matplotlib_modern
plt.plot([1, 2, 3, 4])
plt.xlabel('簡単なグラフ')
plt.show()
インストール
uv add japanize-matplotlib-modern
利用フォント
IPAフォントのIPAexゴシック(Ver.003.01)を利用しています。 利用にあたってはIPAフォントライセンスv1.0 に同意してください。
FAQ
import japanize_matplotlib_modern したのに日本語表示になりません #1
import japanize_matplotlib_modern してから matplotlib でグラフを描画するまでにフォントの設定が変わる処理が入っていると、日本語表示がなされない可能性があります。
例えば、seaborn を利用している場合であれば sns.set() などで描画フォントが seaborn のデフォルトに上書きされ、日本語表示がされなくなります。
sns.set(font="IPAexGothic") のように利用フォントに IPAexGothic を設定するか、フォント上書き後に japanize_matplotlib_modern.japanize() を利用するなどで日本語表示できるはずです。
import のみして利用されないコードなのでフォーマッターに消されてしまいます
リンターなどの警告が気になる・コードを消される方向けに japanize_matplotlib_modern.japanize() メソッドの実行でも import 時と同じくフォントを設定できるようになっています。 無意味な実行になりますが、時と場合に応じて実行してください。
もしくはリンターごとに無視させる設定をすることで対応できるはずです。# noqa などで設定してください。
なぜインストール時は japanize-matplotlib で import 時は japanize_matplotlib_modern なのですか?
チェインケースが読みやすく好きだからです。import時にはチェインケースは利用できないのでスネークケースになっています。
Metadata
Release files for japanize-matlibplot-modern 0.1.4
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_matlibplot_modern-0.1.4.tar.gz | 4.1 MB | Without provenance | Details for japanize_matlibplot_modern-0.1.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| japanize_matlibplot_modern-0.1.4-py3-none-any.whl | Python 3 | none | any | Details for japanize_matlibplot_modern-0.1.4-py3-none-any.whl |
Total release size: 8.3 MB
Release files / japanize_matlibplot_modern-0.1.4.tar.gz
| Download URL | japanize_matlibplot_modern-0.1.4.tar.gz |
|---|---|
| Size | 4.1 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
36cc1de277c94b73e16ce7c8fc825d9e2412cc2779da0d65fa0dfa2fa3bc4db4
|
|
BLAKE2b-256 checksum How to use checksums |
d1793356f7aef5c9e502b38b9348edc8674c7e7a8c948bb97d43cd761e12e970
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.5.4
|
Release files / japanize_matlibplot_modern-0.1.4-py3-none-any.whl
| Download URL | japanize_matlibplot_modern-0.1.4-py3-none-any.whl |
|---|---|
| Size | 4.1 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
255d29521f37f09a90f792274b8cad5d607f40be72743150d30901bfe8bfcb7b
|
|
BLAKE2b-256 checksum How to use checksums |
241b680e9bb72171f93ed593ace133a5a82727e6f51384b020553bc8a9c21b09
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.5.4
|
Security for japanize-matlibplot-modern 0.1.4
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.