LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Selecting one plot to display

Solved!
Go to solution

Hi,
I have a problem i can't wrap my head around. In simplification - let's say I would like to display only one plot (out of many) at a time on my graph. There are tens of plots - using property nodes and constantly choosing which plot to be displayed by setting it as active and its 'visible?' property to true, and then selecting all the other ones as active and setting their 'visible?' property to false seems very inefficient, considering how many properties would the property node have and how many cases would be needed. Is there another way to do it? I would be very grateful for any help.

0 Kudos
Message 1 of 7
(4,417 Views)

@smigam wrote:

 considering how many properties would the property node have and how many cases would be needed. Is there another way to do it? I would be very grateful for any help.


 

You need exactly one property node with two items (active plot, plot visible) and a FOR loop, iterating (autoindexing) over an boolean array of visibilities and having "active plot" wired to the iteration terminal. (Make sure it only executed whenever the visibility changes and not over and over.)

0 Kudos
Message 2 of 7
(4,409 Views)

You may be getting confused between a Graph, which is an Indicator that can display "data", and what I think you mean by a Plot, which is the visualization of a set of Data by wiring it to a Graph.

 

Let's say you have an array of 200 points that you'd like to see on your Graph.  You wire it to the Graph, and bingo, it appears.  Now let's say you have 30 of these arrays of points, in fact, you have a 30 x 200 array of data, and you want to plot the i-th one.  Simply index your array to pull out the i-th row (don't forget the "off-by-one" indexing rule) and write it to your Graph indicator.  It will overwrite the old data, and you are done.

 

Bob Schor

0 Kudos
Message 3 of 7
(4,404 Views)
Solution
Accepted by smigam

On newer LabVIEW versions, there is also the visibility checkbox that can be shown on the plot legend.

 

Here's what I had in mind earlier. This is a useful solution if you want all plots and each plot has it's unique color and style, but you only want to display one at a time. There is also a boolean to show all plot if desired. Modify as needed.

 

ShoOnlyOnePlot.png

Message 4 of 7
(4,400 Views)

Another way I've done it when I had about 40 plots for the user to flip through, is just have a single plot on your graph, and use index array to pick which data set goes to the graph.

Message 5 of 7
(4,390 Views)

Hello,

Is there a way to wrap this in a while loop such that every time you change the "Plot to show" control value, the graph changes ? Thanks! - John

0 Kudos
Message 6 of 7
(3,812 Views)

Yes, but you pretty much answered your own question.  Take the code in Altenbach's solution and draw a while loop around it.  You probably want to add a small (50ms) Wait.vi in the loop so it doesn't eat up CPU cycles.

 

A better way is to use an event structure in your loop that only fires when you change the "Plot to Show" control.

 

Tell us exactly what you're trying to achieve if you need more help than that...

LabVIEW Pro Dev & Measurement Studio Pro (VS Pro) 2019
0 Kudos
Message 7 of 7
(3,809 Views)