Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. 3rd Party Software
  4. Pyqtgraph - calling graph method

Pyqtgraph - calling graph method

Scheduled Pinned Locked Moved Unsolved 3rd Party Software
2 Posts 2 Posters 1.0k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    California
    wrote on last edited by
    #1

    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)
    
    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      I'd recommend contacting this library author(s). This module isn't even part of PyQt.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved