擅长:python、mysql、java
<p>您可以简单地执行以下操作:</p>
<pre class="lang-py prettyprint-override"><code>import numpy as np
import matplotlib.pyplot as plt
x = np.arange(0, 7, 0.01)
plt.subplot(2, 1, 1)
plt.plot(x, np.sin(x))
plt.subplot(2, 2, 3)
plt.plot(x, np.cos(x))
plt.subplot(2, 2, 4)
plt.plot(x, np.sin(x)*np.cos(x))
</code></pre>
<p>即,第一个图实际上是上半部分的图(图仅分为2x1=2个单元格),以下两个较小的图在2x2=4单元格网格中完成。
<code>subplot()</code>的第三个参数是网格内绘图的位置(在英语阅读方向,单元格1位于左上角):
例如,在第二个子图(<code>subplot(2, 2, 3)</code>)中,轴将转到2x2矩阵的第三部分,即左下角</p>
<p><a href="https://i.stack.imgur.com/SeNrA.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SeNrA.png" alt="enter image description here"/></a></p>