📜  matplotlib 并排绘制两个图 - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:14.802000             🧑  作者: Mango

代码示例1
import matplotlib.pyplot as plt
import numpy as np

# Simple data to display 
x = np.linspace(0, 2 * np.pi, 400)
y = np.sin(x ** 2)

# the container holding the two Axes have already been unpacked
# useful if just few Axes have been created
f, (ax1, ax2) = plt.subplots(1, 2) 
ax1.plot(x, y)
ax1.set_title('Left plot')

ax2.scatter(x, y)
ax2.set_title('Right plot')

plt.tight_layout()
plt.show()