Matplotlibの技

基本

import matplotlib.pyplot as plt

# figure()でグラフの表示領域を確保し,figというオブジェクトにする.
fig = plt.figure()

plt.show()

グラフを並べて表示

# add_subplot()でグラフを描画する領域を追加する.引数は行,列,場所
ax1 = fig.add_subplot(2, 2, 1)
ax2 = fig.add_subplot(2, 2, 2)
ax3 = fig.add_subplot(2, 2, 3)
ax4 = fig.add_subplot(2, 2, 4)

# レイアウトの設定
fig.tight_layout()