当前位置 : 主页 > 编程语言 > python >

python_matplotlib自动关闭图表显示窗口

来源:互联网 收集:自由互联 发布时间:2022-06-14
文章目录 ​​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,


文章目录

  • ​​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 numpy as np
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)


网友评论