沉沙
2019-01-21
来源 :
阅读 4786
评论 0
摘要:本篇教程探讨了大数据分析之Python3.x+pyqtgraph实皇冠现体育网站开发数据可视化,希望阅读本篇文章以后大家有所收获,帮助大家对相关内容的理解更加深入。
本篇教程探讨了大数据分析之Python3.x+pyqtgraph实皇冠现体育网站开发数据可视化,希望阅读本篇文章以后大家有所收获,帮助大家对相关内容的理解更加深入。

1、pyqtgraph库数据皇冠体育网站开发 可视化效果还不错,特别是窗体程序中图像交互性较好;安装也很方便,用 pip 安装。
2、在Python中新建一个 .py 文件,然后写入如下代码并执行可以得到官方提供的很多案例(含代码),出现如下界面图像:
import pyqtgraph.examplespyqtgraph.examples.run()
4、程序默认是黑色背景,这个是可以修改的。比如,在程序的开头部分写入如下代码就可以修改背景:
pg.setConfigOption('background', 'w')pg.setConfigOption('foreground', 'k')更多说明,见 pyqtgraph 官网://www.pyqtgraph.org/documentation/style.html,“Line, Fill, and Color”部分的“Default Background and Foreground Colors”部分。
5、一个修改背景颜色的完整案例如下,可以直接运行程序:
import numpy as npimport pyqtgraph as pgfrom pyqtgraph.Qt import QtGui, QtCore# 如下2行代码是我自己加入的,目的是修改默认的黑色背景为其它颜色背景pg.setConfigOption('background', 'w')pg.setConfigOption('foreground', 'k')from pyqtgraph.Point import Point#generate layoutapp = QtGui.QApplication([])win = pg.GraphicsWindow()win.setWindowTitle('pyqtgraph example: crosshair')label = pg.LabelItem(justify='right')win.addItem(label)p1 = win.addPlot(row=1, col=0)p2 = win.addPlot(row=2, col=0)region = pg.LinearRegionItem()region.setZValue(10)# Add the LinearRegionItem to the ViewBox, but tell the ViewBox to exclude this# item when doing auto-range calculations.p2.addItem(region, ignoreBounds=True)#pg.dbg()p1.setAutoVisible(y=True)#create numpy arrays#make the numbers large to show that the xrange shows data from 10000 to all the way 0data1 = 10000 + 15000 * pg.gaussianFilter(np.random.random(size=10000), 10) + 3000 * np.random.random(size=10000)data2 = 15000 + 15000 * pg.gaussianFilter(np.random.random(size=10000), 10) + 3000 * np.random.random(size=10000)p1.plot(data1, pen="r")p1.plot(data2, pen="g")p2.plot(data1, pen="w")def update(): region.setZValue(10) minX, maxX = region.getRegion() p1.setXRange(minX, maxX, padding=0)region.sigRegionChanged.connect(update)def updateRegion(window, viewRange): rgn = viewRange[0] region.setRegion(rgn)p1.sigRangeChanged.connect(updateRegion)region.setRegion([1000, 2000])#cross hairvLine = pg.InfiniteLine(angle=90, movable=False)hLine = pg.InfiniteLine(angle=0, movable=False)p1.addItem(vLine, ignoreBounds=True)p1.addItem(hLine, ignoreBounds=True)vb = p1.vbdef mouseMoved(evt): pos = evt[0] ## using signal proxy turns original arguments into a tuple if p1.sceneBoundingRect().contains(pos): mousePoint = vb.mapSceneToView(pos) index = int(mousePoint.x()) if index > 0 and index < len(data1): label.setText("<span style='font-size: 12pt'>x=%0.1f, <span style='color: red'>y1=%0.1f</span>, <span style='color: green'>y2=%0.1f</span>" % (mousePoint.x(), data1[index], data2[index])) vLine.setPos(mousePoint.x()) hLine.setPos(mousePoint.y())proxy = pg.SignalProxy(p1.scene().sigMouseMoved, rateLimit=60, slot=mouseMoved)#p1.scene().sigMouseMoved.connect(mouseMoved)## Start Qt event loop unless running in interactive mode or using pyside.if __name__ == '__main__': import sys if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'): QtGui.QApplication.instance().exec_()
本文由职坐标整理发布,学习更多的相关知识,请关注职坐标IT知识库!
喜欢 | 1
不喜欢 | 0
您输入的评论内容中包含违禁敏感词
我知道了

请输入正确的手机号码
请输入正确的验证码
您今天的短信下发次数太多了,明天再试试吧!
我们会在第一时间安排职业规划师联系您!
您也可以联系我们的职业规划师咨询:
版权所有 职坐标-一站式AI+学习就业服务平台 沪ICP备13042190号-4
上海海同信息科技有限公司 Copyright ©2015 www.zhizuobiao.com,All Rights Reserved.
沪公网安备 31011502005948号