python - The DateAxisItem sometimes becomes invisible -


i checked out version of pyqtgraph

git clone https://github.com/3rdcycle/pyqtgraph.git git checkout origin/date-axis-item pip uninstall pyqtgraph python setup.py install 

i run program. appears run fine, except x-axes of timestamps goes in , out of view without me doing anything. not sure if bug in program or in dateaxisitem. also, milliseconds multiple of 100. example, see 00:00:00:900, 00:00:01:200, never 00:00:00:042?

# -*- coding: utf-8 -*- """ created on thu may 14 21:09:44 2015  @author: idf """  pyqtgraph.qt import qtgui, qtcore import numpy np import pyqtgraph pg pyside.qtcore import qtime, qtimer collections import deque  t = qtime() t.start() data = deque(maxlen=20)  class timeaxisitem(pg.dateaxisitem):     def __init__(self, *args, **kwargs):         super(timeaxisitem, self).__init__(*args, **kwargs)      def tickstrings(self, values, scale, spacing):         return [qtime().addmsecs(value).tostring('hh:mm:ss.zzz') value in values]  app = qtgui.qapplication([])  win = pg.graphicswindow(title="basic time-plotting examples") win.resize(1000,600)  plot = win.addplot(title='timed data', axisitems={'bottom': timeaxisitem(orientation='bottom')}) curve = plot.plot()  def update():     global plot, curve, data     data.append({'x': t.elapsed(), 'y': np.random.randint(0, 100)})     x = [item['x'] item in data]     y = [item['y'] item in data]     curve.setdata(x=x, y=y)  tmr = qtimer() tmr.timeout.connect(update) tmr.start(800)  if __name__ == '__main__':     import sys     if (sys.flags.interactive != 1) or not hasattr(qtcore, 'pyqt_version'):         qtgui.qapplication.instance().exec_() 

i'm not sure happens dateaxisitem. know it's not yet merged main development branch of pyqtgraph. however, particular application, might easier start scratch , define own timeaxisitem? if start following code, functionality missing?

class timeaxisitem(axisitem):      def __init__(self, orientation, **kwargs):         super().__init__(orientation, **kwargs)      def tickstrings(self, values, scale, spacing):         return [self.get_tick(v, spacing) v in values]      def get_tick(self, ts, spacing):         dt = datetime.datetime.fromtimestamp(ts)         # here can decide on accuracy of time data         # displayed depending on spacing.         if spacing > 60:             return "%02d:%02d" % (dt.hour, dt.minute)         else:             return "%02d:%02d:%02d" % (dt.hour, dt.minute, dt.second) 

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -