Skip to main content

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

Project description

japanize-matplotlib-modern

2025年最新版matplotlib を日本語表示に対応させます

利用方法

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

import matplotlib.pyplot as plt
import japanize_matplotlib

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

インストール

uv add 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時にはチェインケースは利用できないのでスネークケースになっています。

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

japanize_matlibplot_modern-0.1.1.tar.gz (4.1 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

japanize_matlibplot_modern-0.1.1-py3-none-any.whl (4.1 MB view details)

Uploaded Python 3

File details

Details for the file japanize_matlibplot_modern-0.1.1.tar.gz.

File metadata

File hashes

Hashes for japanize_matlibplot_modern-0.1.1.tar.gz
Algorithm Hash digest
SHA256 38fb0280ab3ba8d9601474e8d792ead0df9ec1d7633f3bfe565d2ba1a43b3563
MD5 ef574fa46111f72637c619f4bf5a6e60
BLAKE2b-256 b6714d1b99ef619364f98b6996db16cc36b1228542fb1d3ee1283babe924d609

See more details on using hashes here.

File details

Details for the file japanize_matlibplot_modern-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for japanize_matlibplot_modern-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 12c93ae6c25075bec2a8fae1d2c7388a2771f135fdca791e5cda82d2926bf448
MD5 9139f340cafec8d88aac779628486c09
BLAKE2b-256 d4f668c4045737ef5a69efaa165e0ca96767becf91c9ce89fc00724ee1eafd98

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page