python - Plotting Datetime objects with PyQtGraph -


i new pyqtgraph , need plotting datetime objects on x-axis can done matplotlib. appreciated.

as simple version of id see below want plot datetime objects displayed ticks on x-axis.

the code throws error cannot done.

import pyqtgraph pg pyqtgraph.qt import qtcore, qtgui import datetime  datetimes = ['2014-10-01 00:00:00', '2014-10-02 00:00:00', '2014-10-03 00:00:00'] x = [datetime.datetime.strptime(i, '%y-%m-%d %h:%m:%s') in datetimes] y = [1,2,3]   win = pg.graphicswindow(title = 'plotting') p1 = win.addplot(row=1, col=0, title = 'test') p1.plot(x,y)  if __name__ == '__main__':     import sys     if (sys.flags.interactive != 1) or not hasattr(qtcore, 'pyqt_version'):         qtgui.qapplication.instance().exec_() 

as have found, pyqtgraph not support plotting datetime objects. need convert these numerical value before plotting.

for static zoom, can use axisitem.setticks() customize text displayed on axis.

if want able zoom axis, need make axisitem subclass overrides tickvalues , tickstrings. can see docstrings here: https://github.com/pyqtgraph/pyqtgraph/blob/develop/pyqtgraph/graphicsitems/axisitem.py#l661

..and example, there open pr attempts doing here: https://github.com/pyqtgraph/pyqtgraph/pull/74


Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -