How to show an AxesSubplot in Python?

妖精的绣舞 提交于 2021-02-15 09:53:43

问题


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?


回答1:


You should call matplotlib.pyplot.show(), which is a method that displays all the figures.

If you have imported as plt, then:

import matplotlib.pyplot as plt

# create fig1 (of type plt.figure)
# create fig2

plt.show()  # will display fig1 and fig2 in different windows



回答2:


Alternatively, you could call the figure attribute of your fig2:

fig2.figure 


来源:https://stackoverflow.com/questions/26540567/how-to-show-an-axessubplot-in-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!