如何从分支访问 DateAxisItem

How to access DateAxisItem from a branch

我通过删除现有安装确保没有其他 pyqtgraph:

rm -rf  ~idf/anaconda/lib/python2.7/site-packages/pyqtgraph*

我下载了 b运行ch with date-axis-item with

git clone -b date-axis-item https://github.com/3rdcycle/pyqtgraph.git

然后在下载的 b运行ch 目录中 运行

python setup.py install

当我尝试 运行 这个程序时,它失败了

[idf@localhost python]$ python AxisExample1.py 
Traceback (most recent call last):
  File "AxisExample1.py", line 12, in <module>
    axis = pg.DateTimeAxisItem(orientation='bottom')
AttributeError: 'module' object has no attribute 'DateTimeAxisItem'

请注意我做错了什么?

# -*- coding: utf-8 -*-
"""
Description of example
"""

import pyqtgraph as pg
from pyqtgraph.Qt import QtCore, QtGui
import numpy as np

pg.mkQApp()

axis = pg.DateTimeAxisItem(orientation='bottom')
pw = pg.PlotWidget(axisItems={'bottom': axis})
pw.setWindowTitle('pyqtgraph example: DateTimeAxis')
pw.show()
pw.setXRange(1383960000, 1384020000) 

## Start Qt event loop unless running in interactive mode or using pyside.
if __name__ == '__main__':
    import sys
    if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'):
        QtGui.QApplication.instance().exec_()

git 克隆 https://github.com/3rdcycle/pyqtgraph.git

git结帐origin/date-axis-item

pip 卸载 pyqtgraph

python setup.py 安装

并将您的示例更改为:

# -*- coding: utf-8 -*-
"""
Description of example
"""

import pyqtgraph as pg
from pyqtgraph.Qt import QtCore, QtGui
import numpy as np

pg.mkQApp()

axis = pg.DateAxisItem(orientation='bottom')
pw = pg.PlotWidget(axisItems={'bottom': axis})
pw.setWindowTitle('pyqtgraph example: DateTimeAxis')
pw.show()
pw.setXRange(1383960000, 1384020000) 

## Start Qt event loop unless running in interactive mode or using pyside.
if __name__ == '__main__':
    import sys
    if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'):
        QtGui.QApplication.instance().exe

应该可以。