Pyqtgraph - calling graph method
Unsolved
3rd Party Software
-
Hello to all.
I have simple script for displaying graph with string on x axis which works ok (code below). What I want is to create method in separated module which would be called from main module. When I do this like in second second code tags I got only graph window without any curve.
Thanks in advance.from PyQt4 import QtCore import pyqtgraph as pg x = [58, 59, 0, 1, 2, 3] y = [1, 2, 3, 4, 5, 6] xdict = dict(enumerate(x)) win = pg.GraphicsWindow() stringaxis = pg.AxisItem(orientation='bottom') stringaxis.setTicks([xdict.items()]) plot = win.addPlot(axisItems={'bottom': stringaxis}) curve = plot.plot(xdict.keys(), y) if __name__ == '__main__': import sys if sys.flags.interactive != 1 or not hasattr(QtCore, 'PYQT_VERSION'): pg.QtGui.QApplication.exec_()
Desired method:
def simple_graph(): x = [58, 59, 0, 1, 2, 3] y = [1, 2, 3, 4, 5, 6] xdict = dict(enumerate(x)) win = pg.GraphicsWindow() stringaxis = pg.AxisItem(orientation='bottom') stringaxis.setTicks([xdict.items()]) plot = win.addPlot(axisItems={'bottom': stringaxis}) curve = plot.plot(xdict.keys(), y)
-
Hi,
I'd recommend contacting this library author(s). This module isn't even part of PyQt.