From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Programmatically change plot legend

Solved!
Go to solution

Hello everyone, I have a configuration file 164 rows and 12 columns, column 4 is the sensor name, each row related to different sensors, I would like to assign the sensor name (column 4 value) to the plot name, I'm using index array function within a for loop, I want to assign column #4 value from row 0 to row 7 to plot 1, row 8 to row 15 to plot 2, etc. The way I did here will assign all the values to one plot. Any suggestions? Thank you very much.plot legend.JPG

0 Kudos
Message 1 of 12
(5,246 Views)

Will that code even run? I'm not talking about the property node with unwired inputs, but how does the For loop know how many times to run? You need an autoindexing tunnel or wire the input "N".

0 Kudos
Message 2 of 12
(5,232 Views)

I connect an array and wiring to the edge of the for loop with indexing enabled, it will run. I would like to programmatically change the plot legend of multiple charts, so there is one property node unwired. 

0 Kudos
Message 3 of 12
(5,228 Views)

Xiao@Gemini wrote:

 I'm using index array function within a for loop, I want to assign column #4 value from row 0 to row 7 to plot 1, row 8 to row 15 to plot 2, etc.


Can you explain what you mean by this? Each plot can only have a single name.

 

Did you try using highlight execution to slow it down and see what is being written to each plot? Using Active plot followed by plot name works fine for me...

Capture.PNG

0 Kudos
Message 4 of 12
(5,218 Views)
Solution
Accepted by Xiao@Gemini

Just a quick test, you can probably optimize it :

 EDIT : might be 8 and not 7 as Quotient and Remainder input 😉

 

Xiao_Example.png

 

 

 

CLAMaxime -- Kudos are a great way to say thank you
Message 5 of 12
(5,215 Views)
Solution
Accepted by Xiao@Gemini

Use a case structure where the input to the case structure is the iteration number for the FOR loop. Label your cases "0..7", "8..15", and so on. Put the relevant property node in each case.

 

The case structure can accept numeric integer inputs and can have ranges of values for cases. "0..7" means any input in the range of 0-7 (inclusive) will trigger that case. "8.." means any number >= 8. "..0" means any number <=0.

 

VI snippet attached, drag and drop this into LabVIEW to see what I mean.casestructure.png

 

(Note that I only made one plot and multiple property nodes referencing that same plot, you'll need to change that to one node per structure. You will also need to decrement the ActPlot by the first index you're filtering; otherwise, the second plot will start at ActPlot=8 instead of 1.)

 

Another way to do this would be to use nested Case structures, where each one does a compare on the input number to see if it's within the range of "acceptable" values for that chart.

 

Yet another way to do this would be to use Get Array Subset with indexes at each "delineation" and wire them all up in parallel. That way is probably the "simplest" to use but is the least expandable since everything happens in parallel.

Message 6 of 12
(5,210 Views)

I want to programmatically change plot legend of multiple charts (each chart have 8 plots) with only one reference spreadsheet which has 164 rows.  

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

You have a lot of options as explained in the previous posts 🙂

CLAMaxime -- Kudos are a great way to say thank you
0 Kudos
Message 8 of 12
(5,191 Views)

Xiao@Gemini wrote:

I want to programmatically change plot legend of multiple charts (each chart have 8 plots) with only one reference spreadsheet which has 164 rows.  


I see. Well it looks like others have already given you suggestions down that avenue 🙂

0 Kudos
Message 9 of 12
(5,190 Views)

Excuse me again, how to decrement the ActPlot by the first index you're filtering. Thank you.

0 Kudos
Message 10 of 12
(5,166 Views)