Create two graphs attached with x axis and share x axis

589 views
Skip to first unread message

Upol Ryskulova

unread,
Mar 27, 2015, 8:10:41 AM3/27/15
to pyqt...@googlegroups.com
Hello there,Tyring to plot two real time graphs that share x-axis but have different y-axis with different ranges. I plotted very similar graphs to what I wanted, but it is not an exact graph I wanted. The image is as following. I wrtoe my code based on GraphicsLayout.py sample code. But my plotting needs a really tight modification. Since two graphs have different ranges the y axises are not aligned in parallel. 


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_()



Can you guide me, how can I achieve to that? I am noob in QT and pyqtgraph. Thank you,

Regards,

Upol 


Upol Ryskulova

unread,
Mar 27, 2015, 8:45:36 AM3/27/15
to pyqt...@googlegroups.com
PS : same X-axis but two different Y-axis in opposite direction in a same graph window
Reply all
Reply to author
Forward
0 new messages