LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to plot an XY graph with lines connecting some data but not others?

Solved!
Go to solution

Sorry for the awkward phrasing of the question, I'm not sure what to call it.

 

Basically, I want to plot multiple data sets on the same XY graph (so they can be compared to each other). I want the points of a given data set to be connected by lines (as the XY graph does by default), but I don't want a line to connect them to the following data set (that is, if I pass it data set 1 and then data set 2 a little later, I don't want a line connecting the last point of data set 1 to connect to the first point of data set 2).

 

For example:

 

xygraph1.1.PNG

produces

xygraph1.2.PNG

 

because it's resetting every time by default, I believe. If I make it not reset:

 

xygraph2.1.PNG

all the data sets remain plotted (like I want), but you get that undesirable line I was talking about:

xygraph2.2.PNG

 

So what can I do? I don't know if I should use the express XY graph thing in this situation.

 

If I had to make a wild guess as to a solution, I could do something like, just do the 2nd thing I did, but in between data sets, set a property of the plot style (like the line color or width) such that the connecting line (between data sets) just isn't visible.

 

However there's probably a smarter way. Can anyone help me? thank you.

0 Kudos
Message 1 of 12
(7,250 Views)

You can have multiple plots.  Instead of using the express VI, you are going to use the XY graph property nodes to select which plots you will be drawing to.

 

This snippet gives you a rough idea of what needs to be done.

plot properties.png

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 2 of 12
(7,240 Views)

You have two options:

1. Get rid of the express vi and use regular LabVIEW code to graph multiple plots.

2. Use a single plot and insert a NaN value whenever you want a gap.

0 Kudos
Message 3 of 12
(7,225 Views)
Solution
Accepted by optoelectro

@altenbach wrote:

 

2. Use a single plot and insert a NaN value whenever you want a gap.


Here's a quick example for that. (I assume that you want to possibly update the graph after each trace (e.g. if the loop involves acquisition. A).

 

If you just want to do all traces at once, use a concatenating tunnel instead of a shift register. (B)

 

Download All
0 Kudos
Message 4 of 12
(7,206 Views)

Hi, thanks for the tip.

 

So I tried doing this, but I'm getting a kind of vague error:

 

xygraph4.1.PNG

 

It seems like I'm doing the same thing as in your example, giving the active plot number and then the bundle of arrays... but for some reason it doesn't work...

 

I see the difference that you're doing both plots 0 and 1 at the same time whereas mine is doing it one at a time, but I still don't really get why it isn't working.

0 Kudos
Message 5 of 12
(7,196 Views)

@optoelectro wrote:

 

I see the difference that you're doing both plots 0 and 1 at the same time whereas mine is doing it one at a time, but I still don't really get why it isn't working.


Use my method, it is much cleaner. You typically cannot write to a plot via property node unless that plot already exists. Writing to a plot property also does not adapt the plot automatically to the datatype. I think the "value" is for all plots. I doubt you can select it via "active plot".

 

... and please attach VIs instead of images. We cannot tell the exact datatype from an image/

0 Kudos
Message 6 of 12
(7,192 Views)

You need to use the Build cluster block (not the index and bundle or any other block). The x array should be the first object of the cluster, and the y array should be the second.

 

 

0 Kudos
Message 7 of 12
(7,190 Views)

@altenbach wrote:

@optoelectro wrote:

 

I see the difference that you're doing both plots 0 and 1 at the same time whereas mine is doing it one at a time, but I still don't really get why it isn't working.


Use my method, it is much cleaner. You typically cannot write to a plot via property node unless that plot already exists. Writing to a plot property also does not adapt the plot automatically to the datatype. I think the "value" is for all plots. I doubt you can select it via "active plot".

 

... and please attach VIs instead of images. We cannot tell the exact datatype from an image/


Wow - you're right about the value.  I think I had a power glitch to my brain.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 8 of 12
(7,174 Views)

thank you, this worked!

 

I still kind of can't believe there's not a more native way to do this in labview (your solution is great but definitely a "workaround"), but thank you!

0 Kudos
Message 9 of 12
(7,146 Views)

No, it's the right and native way, not a workaround. Anything else would need much more complicated data structures to maintain information on which points of a plot should be interpolated with a line.

0 Kudos
Message 10 of 12
(7,140 Views)