如何在Python中显示AxesSubplot?
我有一个叫 fig2 的对象,它是一个 mathplotlib.axes.axessubplot 类的实例。但是当我尝试执行 fig2.show() 时,Python 提示说 axessubplot 对象没有 show 这个属性。我该怎么显示 AxesSubplot 呢?
3 个回答
-1
import matplotlib.pyplot as plt
- 这句话可以解决错误。
如果没有第一行,plt.show()
会出现一个属性错误。
plt.show()
38
另外,你可以调用你的 fig2 的 figure 属性:
fig2.figure
69
你应该调用 matplotlib.pyplot.show()
,这是一个用来显示所有图形的方法。
如果你是用 plt
来导入的,那么:
import matplotlib.pyplot as plt
# create fig1 (of type plt.figure)
# create fig2
plt.show() # will display fig1 and fig2 in different windows