Discontinuous line plot?

310 views
Skip to first unread message

Paul, Hsieh-Fu Tsai

unread,
Oct 21, 2015, 8:27:01 PM10/21/15
to pyqtgraph
Hi guys,
I run into a new problem.
I wanted to create a discontinuous line plot (in my case, i'll be turning on and off my controller and i want to show the setpoint only when i turn it on.)
I have been using numpy.array as the data initialization type is float64.
If i insert an empty datapoint, that'll crash the numpy.array.
right now i did a workaround to make the line continuous by inserting a arbitrary data points. (for say like in example at 20. i wishes to show only the part for 37 and for 25)

I did a search in the group and there is a previous discussion about discontinuous line plot. But i didn't really get it.

Is there any way to plot discontinuous line plot?

Thank you very much.
Best,
Paul

vas...@gmail.com

unread,
Oct 22, 2015, 6:59:46 PM10/22/15
to pyqt...@googlegroups.com
Maybe to before the plotting check your array with some "nan" condition, or directly to convert it to zero:
http://docs.scipy.org/doc/numpy/reference/generated/numpy.nan_to_num.html

--
You received this message because you are subscribed to the Google Groups "pyqtgraph" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyqtgraph+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pyqtgraph/96ef7bf2-0ee2-4621-aa6d-7a66706397eb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Paul, Hsieh-Fu Tsai

unread,
Oct 22, 2015, 7:14:36 PM10/22/15
to pyqtgraph
Hi Vasilije,
Thanks for the reply!
But is it possible to stop plotting the line in between nan points in the array??

Best,
Paul

vas...@gmail.com

unread,
Oct 22, 2015, 7:27:56 PM10/22/15
to pyqt...@googlegroups.com
Maybe to in "no data moment" put the next data in a new numpy array and plot more than one line?

vas...@gmail.com

unread,
Oct 25, 2015, 9:49:52 AM10/25/15
to pyqt...@googlegroups.com
This is just my implementation of something that look like a discontinuous line plot. Line will "break" when the cursor's X position is < 0.
discontinuous_line_plot.py

Paul, Hsieh-Fu Tsai

unread,
Oct 28, 2015, 10:01:20 AM10/28/15
to pyqtgraph
Wow Thank you very much for sharing your code Vasilije!
let me work on it to adapt it.
It's really neat!!

Greatly appreciated.

I was thinking about the alternative to put new data in new numpy arrays. But then problem maybe multiple legends.

Thanks alot!
Best,
Paul

Paul, Hsieh-Fu Tsai

unread,
Nov 2, 2015, 7:39:57 PM11/2/15
to pyqtgraph
Dear Vailjije,
Thank you so much.
It work out perfectly.
It's really very educational for me from your code.
Thank so you so much.
Best,
Paul

On Sunday, October 25, 2015 at 10:49:52 PM UTC+9, Vasilije VaskeVanja wrote:

vas...@gmail.com

unread,
Nov 2, 2015, 9:19:15 PM11/2/15
to pyqt...@googlegroups.com
No problem. I try to help everyone if I have time for that.
Cheers,
Vasilije

Reply all
Reply to author
Forward
0 new messages