python matplotlib 动态图_matplotlib怎么读
Pythonmatplotlib 怎么 动态图
2023-06-13 09:11:14 时间
说明
默认情况下,在pycharm中用matplotlib绘制的图形在窗口内,是静态的:
弹出窗口设置
绘制动态图,需先进行相关设置:File–>Settings–>Tools–>Python Scientific–>Show plots in tool window(取消打勾):
代码
利用plt.ion() 开启一个画图的窗口,用于实时更新图表;利用plt.pause(0.5) 设置暂停时间,太快的话图表无法正常显示;利用plt.show()显示图片,防止闪退 示例如下:
# encoding: utf-8
# @author:Jackson
# @file:1.py
# @time:2021/2/24 22:21
import numpy as np
import matplotlib.pyplot as plt
from scipy.special import jn
from IPython.display import display, clear_output
import time
x = np.linspace(0,5)
f, ax = plt.subplots()
ax.set_title("Bessel functions")
plt.ion() # 开启一个画图的窗口,用于实时更新图表
for n in range(1,10):
time.sleep(1)
ax.plot(x, jn(x,n))
clear_output(wait=True)
display(f)
plt.pause(0.5) # 设置暂停时间,太快的话图表无法正常显示
# plt.ioff() # 关闭画图的窗口
plt.show() # 显示图片,防止闪退
# close the figure at the end, so we don't get a duplicate
# of the last plot
plt.close()
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/175170.html原文链接:https://javaforall.cn
相关文章
- 怎么在python中安装matplotlib_matplotlib依赖库
- python提取xml指定内容
- python jieba库_Python jieba库的使用说明「建议收藏」
- Python 命令行工具:Fire (已验证)
- Python入门系列(十)一篇学会python文件处理
- python语言一般用于什么_PYthon
- Python做一个简单的在线编辑器[通俗易懂]
- 【说站】python温度转换代码
- 【说站】python读取txt文件
- 【说站】python数值类型的使用整理
- Python爬虫抓取网站模板的完整版实现
- python调用通达信公式_通达信公式-主力雷达Python化[通俗易懂]
- python中copy.deepcopy_Python eval
- python如何生成随机数_Python生成50个随机数
- 下列python语句的输出结果是print_下列 Python语句的输出结果是「建议收藏」
- python json.loads 中文_Python 的完美 json loads
- Python 异步: 保护任务免于取消(13)
- Python+Matplotlib绘制曲线并实现鼠标跟随的放大镜
- 【7】python_matplotlib 输出(保存)矢量图方法;画图时图例说明(legend)放到图像外侧;Python_matplotlib图例放在外侧保存时显示不完整问题解决
- Python用Lstm神经网络、离散小波转换DWT降噪对中压电网电压时间序列预测
- python面试题及其示例代码
- 好看免费的Python验证码
- Python 的 ChatOps 库:Opsdroid 和 Errbot
- 使用Python连接SQL Server数据库(python连接sqlserver)
- 在Python中简单调用MySQL(python调用mysql)
- Python如何连接MySQL数据库(python怎么连接mysql数据库)
- Python如何使用MySQL构建立连接(python怎么连接mysql)