matplotlib 複数のグラフを表示
# coding: utf-8 import matplotlib.pyplot as plt import numpy as np # データ x = np.linspace(0, 2 * np.pi, 400) y = np.sin(x ** 2) # クリア plt.close('all') # どのように分割するかを行列で指定 f, ax = plt.subplots(2,2) # それぞれの要素に描画 ax[0,0].plot(x, y) ax[0,0].set_title('Simple plot') ax[0,1].plot(-x, -y) ax[0,1].set_title('Reverse Simple plot') ax[1,0].plot(x, y) ax[1,0].set_title('Simple plot') ax[1,1].plot(-x, -y) ax[1,1].set_title('Reverse Simple plot') # 表示 plt.show()
行列で指定できるの便利
参考URL
pylab_examples example code: subplots_demo.py — Matplotlib 1.5.1 documentation