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



Tyring绘制两个共享x轴但具有不同范围的不同y轴的实时图。我绘制了与我想要的非常相似的图形,但这不是我想要的精确图形。图片如下。我编写了基于GraphicsLayout.py示例代码的代码。但我的计划需要严格修改。由于两个图具有不同的范围,y轴不是平行排列的。(我不被允许发布图片,我也在谷歌群组上问了同样的问题)

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

我已经通过设置两个图的边距(setContentsMargins(左、上、下、右))解决了这个问题。

最新更新