0

I want to use pyqtgraph plot a time-price curve.

like this:

I already knew how to set custom axisitem refer

My question is if there was a way to show i needed tick string instead of all?

How to skip these tick string

There is a demo and some data just for example:

import pyqtgraph as pg
from pyqtgraph.Qt import QtCore
time=['09:38:21','09:37:41','09:37:16','09:37:11','09:36:46',
      '09:36:31','09:36:01','09:35:36','09:35:31','09:35:26',
      '09:35:06','09:34:46','09:34:06','09:33:41','09:33:36',
      '09:33:21','09:33:16','09:33:11','09:33:01','09:32:46',
      '09:32:36','09:32:26','09:32:16','09:32:01','09:31:46',
      '09:31:41','09:31:21','09:30:46','09:30:06','09:25:06']
price=[6.08,6.08,6.07,6.09,6.09,6.09,6.09,6.09,6.08,6.09,6.09,
       6.09,6.09,6.07,6.07,6.06,6.06,6.06,6.06,6.06,6.07,6.08,
       6.08,6.07,6.07,6.07,6.08,6.08,6.08,6.09 ]

xDict=dict(enumerate(time))
xValue=list(xDict.keys())

win = pg.GraphicsWindow()
bottomAxis = pg.AxisItem(orientation='bottom')
plot = win.addPlot(axisItems={'bottom': bottomAxis},name='price')
xtickts=[xDict.items()]
bottomAxis.setTicks(xtickts)
plot.plot(xValue,price)
if __name__ == '__main__':
   import sys
   if sys.flags.interactive != 1 or not hasattr( QtCore, 'PYQT_VERSION' ):
      pg.QtGui.QApplication.exec_()

How can I avoid show all the time tick string?

Zheng Shao
  • 23
  • 4
  • SO is not a coding service, you should try to solve your problem and if you have a problem you just post a question, at that time we will try to help you with recommendations or possible solutions, I recommend you read the following to improve your question: [How do I ask a good question?](https://stackoverflow.com/help/how-to-ask) – eyllanesc Nov 19 '17 at 04:51
  • Well,I post the code and some test data. – Zheng Shao Nov 19 '17 at 06:14

1 Answers1

0

When you define setTicks you define every tick as major tick. If you instead give it two lists the second list will be for minor ticks, see: http://www.pyqtgraph.org/documentation/graphicsItems/axisitem.html#pyqtgraph.AxisItem.setTicks

For your problem you could change xtickts to

xtickts=[list(xDict.items())[::2], list(xDict.items())[1::2]]

Then if you zoom the strings for the minorticks will become visible.

Also same question: How to plot time series without showing all points?

luddek
  • 869
  • 5
  • 7