博客
关于我
python可视化编程--matplotlib
阅读量:657 次
发布时间:2019-03-14

本文共 1070 字,大约阅读时间需要 3 分钟。

matplotlib与pyqtgraph

matplotlib 和 pyqtgraph 是两种常用的数据可视化库,各有其优势和适用场景。

matplotlib

matplotlib 是一种功能强大的绘图库,提供了丰富的图表类型和灵活的API,适合生成静态图形和交互式绘图。它的学习曲线较低,开发者可以通过简单的命令生成如直方图、散点图等图形,且支持嵌入到 GUI 应用程序中。

pyqtgraph

pyqtgraph 是一种基于 PyQt4/PySide 和 numpy 的纯 Python 图形库,适合处理大数据量和快速绘图更新。它支持 2D 和 3D 绘图,适合实时交互和动态图形应用。

环境配置

安装 numpy、scipy 和 matplotlib 是使用这些库的前提。安装完成后,可以通过命令检查安装情况。

简单实例

import matplotlib.pyplot as plt# 绘制简单的直方图data = [1, 9, 9, 16, 25]plt.plot(data)plt.show()
# 绘制多条线plt.plot([1, 25, 7], [5, 7, 4], [15, 18, 2], linewidth=5)plt.title('函数图像', fontsize=24)plt.xlabel('x轴')plt.ylabel('y轴')plt.tick_params(axis='both', labelsize=14)plt.show()
import numpy as npimport matplotlib.pyplot as plt# 生成正弦和余弦函数图像x = np.arange(-1 * np.pi, 1 * np.pi, 0.01)y = np.cos(x)y1 = np.sin(x)plt.plot(x, y, x, y1)plt.title('函数图像', fontsize=24)plt.xlabel('x轴')plt.ylabel('y轴')plt.show()

隐藏轴

ax = plt.gca()ax.spines['right'].set_color('none')ax.spines['top'].set_color('none')ax.xaxis.set_ticks_position('bottom')ax.yaxis.set_ticks_position('left')plt.show()

matplotlib 和 pyqtgraph 各有优劣,选择时需根据项目需求决定。

转载地址:http://azvoz.baihongyu.com/

你可能感兴趣的文章
npm install报错,证书验证失败unable to get local issuer certificate
查看>>
npm install无法生成node_modules的解决方法
查看>>
npm install的--save和--save-dev使用说明
查看>>
npm node pm2相关问题
查看>>
npm run build 失败Compiler server unexpectedly exited with code: null and signal: SIGBUS
查看>>
npm run build报Cannot find module错误的解决方法
查看>>
npm run build部署到云服务器中的Nginx(图文配置)
查看>>
npm run dev 和npm dev、npm run start和npm start、npm run serve和npm serve等的区别
查看>>
npm run dev 报错PS ‘vite‘ 不是内部或外部命令,也不是可运行的程序或批处理文件。
查看>>
npm scripts 使用指南
查看>>
npm should be run outside of the node repl, in your normal shell
查看>>
npm start运行了什么
查看>>
npm WARN deprecated core-js@2.6.12 core-js@<3.3 is no longer maintained and not recommended for usa
查看>>
npm 下载依赖慢的解决方案(亲测有效)
查看>>
npm 安装依赖过程中报错:Error: Can‘t find Python executable “python“, you can set the PYTHON env variable
查看>>
npm.taobao.org 淘宝 npm 镜像证书过期?这样解决!
查看>>
npm—小记
查看>>
npm上传自己的项目
查看>>
npm介绍以及常用命令
查看>>
NPM使用前设置和升级
查看>>