python:matplotlib:文字の設定
Differences
This shows you the differences between two versions of the page.
python:matplotlib:文字の設定 [2018/01/21 20:08] – 作成 koudai | python:matplotlib:文字の設定 [2018/01/21 20:12] (current) – 削除 koudai | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== 概要 ====== | ||
- | matplotlibで使われる文字の大きさやフォントの種類の設定方法を紹介します。 | ||
- | |||
- | |||
- | |||
- | ====== まとめて設定 ====== | ||
- | |||
- | グラフに登場するすべてのフォントを同じ大きさ、同じフォントにする場合は plt.rcParam を使うと便利です。 | ||
- | |||
- | <file python plot.py> | ||
- | import numpy as np | ||
- | import matplotlib.pyplot as plt | ||
- | |||
- | plt.rcParams[" | ||
- | plt.rcParams[" | ||
- | |||
- | x = np.arange(-5, | ||
- | y = np.sin(x) | ||
- | |||
- | plt.title(" | ||
- | plt.xlabel(" | ||
- | plt.ylabel(" | ||
- | |||
- | plt.plot(x, y, label=" | ||
- | |||
- | plt.legend(loc=" | ||
- | |||
- | plt.tick_params() | ||
- | plt.tight_layout() | ||
- | |||
- | plt.show() | ||
- | </ | ||
- | |||
- | |||
- | ====== 個別に設定 ====== | ||
- | |||
- | フォントのサイズを個別に設定する場合は、各文字の出力のときに fontsize を指定します。 | ||
- | |||
- | |||
- | <file python plot.py> | ||
- | import numpy as np | ||
- | import matplotlib.pyplot as plt | ||
- | |||
- | x = np.arange(-5, | ||
- | y = np.sin(x) | ||
- | |||
- | plt.title(" | ||
- | plt.xlabel(" | ||
- | plt.ylabel(" | ||
- | |||
- | plt.plot(x, y, label=" | ||
- | |||
- | plt.legend(loc=" | ||
- | |||
- | plt.tick_params(labelsize = 20) | ||
- | plt.tight_layout() | ||
- | |||
- | plt.savefig(" | ||
- | </ |
python/matplotlib/文字の設定.1516532918.txt.gz · Last modified: 2021/06/27 21:59 (external edit)