python 3.5 - Pyqtgraph string in x tick -
so have been playing pyqtgraph , came problem needed add strings x axis tick label (instead of default float). looked around , found show string values on x-axis in pyqtgraph
the solution kind of need (the first solution on page, second 1 cause problems because on python 3.5). tried modified first solution, did not work.
from pyqt4 import qtcore import pyqtgraph pg x = ['a', 'b', 'c', 'd', 'e', 'f'] 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_()
the error getting typeerror: 'dict_keys' object not support indexing on line
curve = plot.plot(xdict.keys(),y)
i tried turning list, doing follows:
curve = plot.plot(list(sdict.keys(),y))
but made output has small problem
the problem there axis added top left of plot. can tell me doing wrong here?
well not sure if answer own question looked , found https://stackoverflow.com/help/self-answer. here answer.
go pyqtgraph google group https://groups.google.com/forum/#!searchin/pyqtgraph/string|sort:relevance/pyqtgraph/psin0xngoda/79pr3dublaaj , question upol ryskulova. asking exact same question. responses comment confirm bug in pyqtgraph. has been fixed fix has not yet propagated anaconda distribution. need wait time , bug go away. fix discussed in group, , there nothing wrong code.
Comments
Post a Comment