博客
关于我
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/

你可能感兴趣的文章
Python Shell下使用matplotlib
查看>>
Python Slice How-to,我知道Python Slice,但我怎么才能使用内置的Slice对象呢?
查看>>
python socket分包发送数据
查看>>
python socket模块_Python socket模块实现TCP服务端客户端
查看>>
Python SOCKS5代理客户端HTTPS
查看>>
Python Soc网络分析:通过使用函数迭代列表来计算机会网络
查看>>
python转换已转义的字符串
查看>>
Python Sphinx自动摘要:成员函数的自动列表
查看>>
Python SQL和NoSQL数据库操作实战
查看>>
python stdout flush_sys.stdout.flush()方法的用法
查看>>
python string 运算
查看>>
Python str与bytes之间的转换
查看>>
Python subprocess ffmpeg
查看>>
python subprocess Permission denied Errno 13
查看>>
Python subprocess.call - 将变量添加到 subprocess.call
查看>>
Python Subprocess.Popen 从一个线程
查看>>
Python subprocess.Popen 作为 Windows 上的不同用户
查看>>
Python转换PPT为PDF
查看>>
Python subprocess.Popen() 等待完成
查看>>
Python sum 二维列表中具有相同第一个值的元素
查看>>