cancel
Showing results for 
Search instead for 
Did you mean: 

Programmatically change plot legend

SOLVED
Xiao@Gemini
Member
Solved!

Programmatically change plot legend

Message contains an image

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

Tags (1)
11 REPLIES 11
Gregory
Trusted Enthusiast

Re: Programmatically change plot legend

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".

Highlighted
Xiao@Gemini
Member

Re: Programmatically change plot legend

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. 

Gregory
Trusted Enthusiast

Re: Programmatically change plot legend

Message contains an image

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

ML927
Active Participant
Solution

Re: Programmatically change plot legend

Message contains an image

Just a quick test, you can probably optimize it :

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

 

Xiao_Example.png

 

 

 

CLAMaxime -- Kudos are a great way to say thank you
BertMcMahan
Trusted Enthusiast
Solution

Re: Programmatically change plot legend

Message contains an image

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.

Xiao@Gemini
Member

Re: Programmatically change plot legend

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

ML927
Active Participant

Re: Programmatically change plot legend

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

CLAMaxime -- Kudos are a great way to say thank you
Gregory
Trusted Enthusiast

Re: Programmatically change plot legend


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 Smiley Happy

Xiao@Gemini
Member

Re: Programmatically change plot legend

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