如何设置python_matplotlib图表不自动关闭显示窗口?
- 内容介绍
- 文章标签
- 相关推荐
本文共计336个文字,预计阅读时间需要2分钟。
文章目录 + code + code使用matplotlib.pyplot.pause(showTime)实现显示和定时关闭操作:运行GUI事件循环,间隔秒数。如果存在活动图形,它将在暂停之前更新并显示:运行GUI事件循环,间隔秒数。如果存在活动图形,它将在暂停前更新并显示。
文章目录
- code
code
使用matplotlib.pylot.pause(showTime)
即可完成显示和定时关闭操作:
Run the GUI event loop for interval seconds.
If there is an active figure, it will be updated and displayed before the pause, and the GUI event loop (if any) will run during the pause.
This can be used for crude animation. For more complex animation use matplotlib.animation.
If there is no active figure, sleep for interval seconds instead.
import matplotlib.pyplot as plt
mu,sigma=100,15
x=mu+sigma*np.random.randn(10000)
n,bins,patches=plt.hist(x,50,density=1,facecolor='g',alpha=0.75)
plt.xlabel('Smarts')
plt.ylabel('Probability')
plt.title('Histogram of IQ')
""" 文字部分支持latex语法()
DESCRIPTION
Add text to the axes.
Add text in string s to axis at location x, y, data coordinates.
PARAMETERS
x, y : scalars
data coordinates
s : string
text"""
plt.text(66,.0025, r'$\mu=100,\ \sigma=15$')
""" Convenience method to get or set axis properties. """
plt.axis([40,160,0,0.03])
plt.grid(True)
# plt.show()
# time.sleep(2)
plt.pause(3)
本文共计336个文字,预计阅读时间需要2分钟。
文章目录 + code + code使用matplotlib.pyplot.pause(showTime)实现显示和定时关闭操作:运行GUI事件循环,间隔秒数。如果存在活动图形,它将在暂停之前更新并显示:运行GUI事件循环,间隔秒数。如果存在活动图形,它将在暂停前更新并显示。
文章目录
- code
code
使用matplotlib.pylot.pause(showTime)
即可完成显示和定时关闭操作:
Run the GUI event loop for interval seconds.
If there is an active figure, it will be updated and displayed before the pause, and the GUI event loop (if any) will run during the pause.
This can be used for crude animation. For more complex animation use matplotlib.animation.
If there is no active figure, sleep for interval seconds instead.
import matplotlib.pyplot as plt
mu,sigma=100,15
x=mu+sigma*np.random.randn(10000)
n,bins,patches=plt.hist(x,50,density=1,facecolor='g',alpha=0.75)
plt.xlabel('Smarts')
plt.ylabel('Probability')
plt.title('Histogram of IQ')
""" 文字部分支持latex语法()
DESCRIPTION
Add text to the axes.
Add text in string s to axis at location x, y, data coordinates.
PARAMETERS
x, y : scalars
data coordinates
s : string
text"""
plt.text(66,.0025, r'$\mu=100,\ \sigma=15$')
""" Convenience method to get or set axis properties. """
plt.axis([40,160,0,0.03])
plt.grid(True)
# plt.show()
# time.sleep(2)
plt.pause(3)

