2

Im plotting with pyqtgraph but I am stuck trying to represent with values that I need in the X axis:

I have a list with int values, which it was got from a xml file.

XX ==  [91049, 91049, 91049, 91049, 91049, 91051, 91057, 9110, 9110, 9118, 91111, 91111, 91119, 91122, 91122, 91130, 91133, 91133, 91142, 91145, 91145, 91153]

the right way to read that values is: XX[0]=9:10:49, XX[1]=9:10:49, ... , XX[n-1]==9:11:45, XX[n]=9:11:53

How can I code in order to show in the X axis the right format, it says, 9:10:49

To note that the values inside of list must be int, not string in order to plot with pyqtgraph so I can't to write down directly and pass to the function:

self.graphicsView.plot(XX,YY, pen='r', symbolBrush=(255,255,100), symbol='d', symbolPen='g')

So, there are a way to pass to the function graphicsView.plot the right format, it says: 9:10:49?

or there are another unknown-way for me?

thanks

::::::::::: UPDATE :::::::::::::::::

following the post: Show string values on x-axis in pyqtgraph

i got the error:

could not convert string to float: '9:10:49'

i changed the line to plot with:

self.graphicsView.plot(list(XXX.value()),YY, pen=(255,0,0), name='red', symbolBrush=(255,0,0), symbolPen='w')

and also code: XXX=dict(enumerate(X))

So, XXX now is a dict as follow:

{0: '9:10:49', 1: '9:10:49', 2: '9:10:49', 3: '9:10:49', 4: '9:10:49', 5: '9:10:51', 6: '9:10:57', 7: '9:11:00', 8: '9:11:00', 9: '9:11:08', 10: '9:11:11', 11: '9:11:11', 12: '9:11:19', 13: '9:11:22', 14: '9:11:22', 15: '9:11:30', 16: '9:11:33', 17: '9:11:33', 18: '9:11:42', 19: '9:11:45', 20: '9:11:45', 21: '9:11:53'}

it try to plot x axis with time values with a hr:mm:ss format but it seems that self.graphicView.plot() try to convert to float each value from the list XXX.

How can i trick to the function in order to convert ':' value as a float

Or maybe is better another kind of solution ? i am really lost

donostialdea
  • 75
  • 1
  • 7
  • following this post: https://stackoverflow.com/questions/31775468/show-string-values-on-x-axis-in-pyqtgraph – donostialdea Nov 01 '18 at 19:18
  • According to `91049` it corresponds to `9:10:49`, what time does it correspond to `9110`?, you could also share the .xml – eyllanesc Nov 01 '18 at 19:46
  • thanks for comment and sorry for the confusion I did edit the post. I have a dict as it is recommended in the post, labeled XXX. All the values of this dict has a time format: 0:00:00. But when run self.graphicsView.plot raised an error: could not convert string to float: '9:10:49' – donostialdea Nov 01 '18 at 20:47
  • is that there is no clear correspondence rule, as I see if the number has 5 digits the format is hmmss -> h:mm:ss but if it has 4 the format is hmms -> h:mm:s o h:m:ms which of the 2 is?, you could explain the rule of correspondence and thus avoid confusion, ie for a number n how to get h, mys in h:m:s – eyllanesc Nov 01 '18 at 20:53
  • The format of time values of the list is always the same, i mean, as we can see on the XXX list, it has the same key-value-format: 0: '9:10:49', 1: '9:10:49', 2: '9:10:49', ..., 20: '9:11:45', 21: '9:11:53'} So, i supposed that the rule of correspondence is not important because the raised error is: could not convert string to float: '9:10:49' ... Plus, following the second implementation of https://stackoverflow.com/questions/31775468/show-string-values-on-x-axis-in-pyqtgraph running the code, in the x axis paint nothing on my computer... As i tell you i really lost – donostialdea Nov 01 '18 at 21:18
  • your input: XX == [91049, 91049, 91049, 91049, 91049, 91051, 91057, **9110**, --> `7: '9:11:00'`.for example if I had the string `"9:11:00"` I would expect the input to be `91100` but in your case you have as entry `9110` which is what causes me confusion. – eyllanesc Nov 01 '18 at 21:19

0 Answers0