如何在 Python 中显示 AxesSubplot?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26540567/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to show an AxesSubplot in Python?
提问by user3765587
I have an object fig2 that is a class mathplotlib.axes.axessubplot, but when I try to execute fig2.show(), python says axessubplot object has no attribute show. How can I show AxesSubplot?
我有一个对象 fig2,它是一个类 mathplotlib.axes.axessubplot,但是当我尝试执行 fig2.show() 时,python 说 axessubplot 对象没有属性显示。如何显示 AxesSubplot?
采纳答案by heltonbiker
You should call matplotlib.pyplot.show(), which is a method that displays all the figures.
您应该调用matplotlib.pyplot.show(),这是一种显示所有数字的方法。
If you have imported as plt, then:
如果您已导入为plt,则:
import matplotlib.pyplot as plt
# create fig1 (of type plt.figure)
# create fig2
plt.show() # will display fig1 and fig2 in different windows
回答by Bython
Alternatively, you could call the figure attribute of your fig2:
或者,您可以调用 fig2 的 figure 属性:
fig2.figure

