2017年9月20日水曜日

グラフのタイトル・ラベル・補助線を表示する

前回のグラフにタイトルやラベルを表示する。タイトルは matplotlib.pyplot.title関数、ラベルは matplotlib.pyplot.xlabel 関数(x軸のラベル)、matplotlib.pyplot.xlabel 関数(y軸のラベル)を使用する。
なお、表示データは前回のものを使用する。
import matplotlib.pyplot as plt

plt.title("The Population of Italy")
plt.xlabel("YEAR")
plt.ylabel("Thousand unit", fontproperties=fp)
plt.plot(x, y)
plt.show()
また、補助線を表示したい場合は、matplotlib.pyplot.grid関数の引数に True を与えればよい。
plt.grid(True)

0 件のコメント:

コメントを投稿