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

你可能感兴趣的文章
sqlserver学习笔记(三)—— 为数据库添加新的用户
查看>>
org.apache.http.conn.HttpHostConnectException: Connection to refused
查看>>
org.apache.ibatis.binding.BindingException: Invalid bound statement错误一例
查看>>
org.apache.ibatis.exceptions.PersistenceException:
查看>>
org.apache.ibatis.exceptions.TooManyResultsException: Expected one result (or null) to be returned
查看>>
org.apache.ibatis.type.TypeException: Could not resolve type alias 'xxxx'异常
查看>>
org.apache.poi.hssf.util.Region
查看>>
org.apache.xmlbeans.XmlOptions.setEntityExpansionLimit(I)Lorg/apache/xmlbeans/XmlOptions;
查看>>
org.apache.zookeeper.KeeperException$ConnectionLossException: KeeperErrorCode = ConnectionLoss for /
查看>>
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:processDebugManifest'
查看>>
org.hibernate.HibernateException: Unable to get the default Bean Validation factory
查看>>
org.hibernate.ObjectNotFoundException: No row with the given identifier exists:
查看>>
org.springframework.amqp.AmqpConnectException:java.net.ConnectException:Connection timed out:connect
查看>>
org.springframework.beans.factory.BeanDefinitionStoreException
查看>>
org.springframework.boot.context.properties.ConfigurationBeanFactoryMetadata
查看>>
org.springframework.boot:spring boot maven plugin丢失---SpringCloud Alibaba_若依微服务框架改造_--工作笔记012
查看>>
SQL-CLR 类型映射 (LINQ to SQL)
查看>>
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
查看>>
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
查看>>
org.springframework.web.multipart.MaxUploadSizeExceededException: Maximum upload size exceeded
查看>>