Pyqtgraph:在同一个图形窗口中绘制实时两个图形相同的X轴但在相反方向上的两个不同的Y轴

问题描述 投票:0回答:1

Tyring绘制两个共享x轴但具有不同y轴和不同范围的实时图形。我将非常相似的图形绘制成我想要的图形,但它不是我想要的精确图形。图像如下。我基于GraphicsLayout.py示例代码编写了我的代码。但我的阴谋需要一个非常严格的修改。由于两个图具有不同的范围,因此y轴不平行排列。 (我不允许发布图片,我也在google group上问了同样的问题)

from pyqtgraph.Qt import QtGui, QtCore
import pyqtgraph as pg
import numpy as np

app = QtGui.QApplication([])
view = pg.GraphicsView()
l = pg.GraphicsLayout(border=(100,100,100))
view.setCentralItem(l)
view.show()
view.setWindowTitle('pyqtgraph example: GraphicsLayout')
view.resize(800,600)


l2 = l.addLayout(colspan=3, border=(50,0,0))
l2.setContentsMargins(10, 10, 10, 10)
l2.addLabel("Sub-layout: this layout demonstrates the use of shared    axes and axis labels", colspan=3)
l2.nextRow()
l2.addLabel('Vertical Axis Label', angle=-90, rowspan=2)
p21 = l2.addPlot()
p21.setYRange(0,1000)
l2.nextRow()
p23 = l2.addPlot()
p23.setYRange(0,50)
l2.nextRow()
l2.addLabel("HorizontalAxisLabel", col=1, colspan=1)

## hide axes on some plots
p21.hideAxis('bottom')
p21.hideButtons()
p23.hideButtons()

## Start Qt event loop unless running in interactive mode.
if __name__ == '__main__':
    import sys
    if (sys.flags.interactive != 1) or not hasattr(QtCore,   'PYQT_VERSION'):
        QtGui.QApplication.instance().exec_()

你能指导我,我怎么能达到这个目的?我在QT和pyqtgraph中是菜鸟。谢谢,问候,Upol

python qt graph pyqtgraph
1个回答
0
投票

我通过设置两个图形的边距来解决这个问题(setContentsMargins(left,top,bottom,right))。

© www.soinside.com 2019 - 2024. All rights reserved.