@Carlos Here are both the UI and the compiled version. On Tuesday, September 27, 2016 at 11:04:14 PM UTC-5, MudloggerMike wrote: > > > <https://lh3.googleusercontent.com/-gAP0_Jp0-aw/V-tAqE3YBhI/AAAAAAAAABY/kQ6_856NotESHEO2mIDDGfbKt7qM9RIbACLcB/s1600/mplot.png> > > I am new to pyqtgraph. I modified a multiaxis example that I found on the > Internet and placed into a PyQt4 GraphicsView widget. The example shows the > third axis before I embedded into the GUI, however when I embed, the third > axis doesn't show up. I have read everything that I can find with no luck. > Can someone please help? Ideally, I would like for the third axis to appear > just to the right of the second axis.The graph is pictured above. Here is > the code: > > > #imports > from PyQt4 import QtGui > from PyQt4 import QtCore > import ui_test #Gui File > import sys > import pyqtgraph as pg > > class Gui(QtGui.QMainWindow, ui_test.Ui_MainWindow): > def __init__(self): > super(self.__class__, self).__init__() > self.setupUi(self) > self.pg_plot() > self.updateViews() > self.plotdata() > self.pushButton_movecursor.clicked.connect(self.movecursor) > > def pg_plot(self): > ## Switch to using white background and black foreground > self.bepx = 30 > self.bepy = 800 > pg.setConfigOption('background', 'w') > pg.setConfigOption('foreground', 'k') > lr = pg.LinearRegionItem([20,40], movable = False, brush = > '#ffcccc33') #Set linear region > self.p1 = pg.PlotItem() > > self.p1.addItem(lr) > self.graphicsView.setCentralWidget(self.p1) > self.p1.showGrid(x = True, y = True ,alpha = 0.3) > ## create a new ViewBox, link the right axis to its coordinate > system > self.p2 = pg.ViewBox() > > self.p1.showAxis('right') > self.p1.scene().addItem(self.p2) > self.p1.getAxis('right').linkToView(self.p2) > self.p2.setXLink(self.p1) > self.p1.getAxis('right').setLabel('eff', color='g') > pg.LinearRegionItem([20,40]) > > ## create third ViewBox. > ## this time we need to create a new axis as well. > self.p3 = pg.ViewBox() > ax3 = pg.AxisItem('right') > self.p1.layout.addItem(ax3,2,3) > self.p1.scene().addItem(self.p3) > ax3.linkToView(self.p3) > self.p3.setXLink(self.p1) > ax3.setZValue(-10000) > ax3.setLabel('Power', color='r') > > self.arrow = pg.ArrowItem(angle=90) > self.text = pg.TextItem(html='<div style="text-align: > center"><span style="color: 'b' ;">^</span><br><span style="color: #000; > font-size: 16pt;">BEP</span></div>', anchor=(-0.3,1.3), border='w', > fill=(255, 255, 255, 100)) > self.p3.addItem(self.text) > > self.p3.addItem(self.arrow) > self.text.setPos(self.bepx - 1.2, self.bepy - 530) > ax3.setStyle(showValues=False) #Not needed workig on gridlines > > ## Handle view resizing > def updateViews(self): > ## view has resized; update auxiliary views to match > > self.p2.setGeometry(self.p1.vb.sceneBoundingRect()) > self.p3.setGeometry(self.p1.vb.sceneBoundingRect()) > > ## need to re-update linked axes since this was called > ## incorrectly while views had different shapes. > ## (probably this should be handled in ViewBox.resizeEvent) > self.p2.linkedViewChanged(self.p1.vb, self.p2.XAxis) > self.p3.linkedViewChanged(self.p1.vb, self.p3.XAxis) > > def plotdata(self): > #Plot Datapoints > self.p1.plot([0,10,20,30,40,50], [1,2,4,8,16,32], pen = 'g') > self.p2.addItem(pg.PlotCurveItem([0,10,20,30,40,50], > [10,20,40,80,40,20], pen='b')) > self.p3.addItem(pg.PlotCurveItem([0,10,20,30,40,50], > [3200,1600,800,2500,200,100], pen='r')) > self.bepx = 50 > self.bepy = 1000 > > x = 1 > y = 1 > def movecursor(self): > try: > self.cursor.clear() > except: > pass > self.x += 1 > if self.x > 50: > self.x = 1 > self.y += 1 > if self.y > 30: > self.y = 1 > > self.cursor = self.p1.plot([self.x], [self.y], pen=None, > symbol='+', color = 'b') > > def main(): > app = QtGui.QApplication(sys.argv) > form = Gui() > form.show() > app.exec_() > > if __name__ == '__main__': # if we're running file directly and not > importing it > main() # run the main function > > > > > >
-- You received this message because you are subscribed to the Google Groups "pyqtgraph" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/pyqtgraph/b1877af2-220b-44eb-b7da-c6bd19164345%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'ui_test.ui'
#
# Created: Mon Sep 26 11:40:33 2016
# by: PyQt4 UI code generator 4.11.3
#
# WARNING! All changes made in this file will be lost!
from PyQt4 import QtCore, QtGui
try:
_fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
def _fromUtf8(s):
return s
try:
_encoding = QtGui.QApplication.UnicodeUTF8
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig)
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName(_fromUtf8("MainWindow"))
MainWindow.resize(2307, 1545)
self.centralwidget = QtGui.QWidget(MainWindow)
self.centralwidget.setObjectName(_fromUtf8("centralwidget"))
self.graphicsView = PlotWidget(self.centralwidget)
self.graphicsView.setGeometry(QtCore.QRect(100, 50, 1121, 451))
self.graphicsView.setObjectName(_fromUtf8("graphicsView"))
self.pushButton_movecursor = QtGui.QPushButton(self.centralwidget)
self.pushButton_movecursor.setGeometry(QtCore.QRect(100, 580, 93, 28))
self.pushButton_movecursor.setObjectName(_fromUtf8("pushButton_movecursor"))
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtGui.QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 2307, 26))
self.menubar.setObjectName(_fromUtf8("menubar"))
MainWindow.setMenuBar(self.menubar)
self.statusbar = QtGui.QStatusBar(MainWindow)
self.statusbar.setObjectName(_fromUtf8("statusbar"))
MainWindow.setStatusBar(self.statusbar)
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow", None))
self.pushButton_movecursor.setText(_translate("MainWindow", "Move Cursor", None))
from pyqtgraph import PlotWidget
ui_test.ui
Description: Binary data
