我想使用
有没有其他方法可以做到呢?
python
和 matplotlib
同时绘制两个或多个图形。 我不想使用 subplot,因为它实际上是在同一张画纸上画两个或多个图形。有没有其他方法可以做到呢?
python
和 matplotlib
同时绘制两个或多个图形。 我不想使用 subplot,因为它实际上是在同一张画纸上画两个或多个图形。您可以使用多个图形展示不同的数据。最简单的做法是调用 plt.figure()
并使用 pyplot 库。
import matplotlib.pyplot as plt
plt.figure() # creates a figure
plt.plot([1,2,3])
plt.figure() # creates a new figure
plt.plot([3,2,1])
plt.show() # opens a window for each of the figures
plt.figure(1)
plt.plot([2,3,1]) # this is plotted to the first figure.
(图号从1开始)
matplotlib.pyplot.figure()
会为您打开一个新的图形窗口,如果这是您的意思的话。 - Andras Deak -- Слава Україніmatplotlib.pyplot.figure()
中指定以英寸为单位的宽度和高度,使用figsize=(width,height)
来使图形更大,并且可以使用子图。 - Pablo Reyes