LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Strange behaviour of plot (plot legend)

Solved!
Go to solution

Hello,
I'll try to explain as best as possible given I'm a novice in LV. The code for the state machine project along with some example data is attached below in the zip file. I'll always refer to the first tab named 'RingDown Times' regarding the problem described below. 
The logic of the code is following: If the binary is True, the plot should appear once the user hits the plot button. The colour of the resulting plots should follow the values of the colour box of the corresponding data path. This is how it looks like in the front panel:

SudiptaDas_0-1688570973479.png

There is apparently no problem if all the booleans are True. The problem becomes apparent if one or several of them are false. E.g. in the example below, the first boolean is False. Notice how the plot changes: 

SudiptaDas_1-1688571126865.png

The colour of the plots seems to have shifted by one i.e. the plot which is supposed to be red, is now black, and so on and so forth. Notice that the colour of the last plot is supposed to be pink, but it's green instead.

I'd appreciate if someone can explain me the reason for this. Any suggestion to correct it is most welcome.
I've coded it in LV2021 community version.

0 Kudos
Message 1 of 7
(1,024 Views)

(Please use zip for attachments. Nobody should be forced to download extra software just to open your attachments!)

 

You are changing the order of the data. Why not keep plotting all, but change the visibility of each plot based on the boolean?

0 Kudos
Message 2 of 7
(992 Views)
0 Kudos
Message 3 of 7
(988 Views)

"You are changing the order of the data. "
I am not sure how I'm changing the order of the data. Can you please elaborate.

"Why not keep plotting all, but change the visibility of each plot based on the boolean?"
I imagine you are referring to property node -> Graph -> Plot Legend Visible : passing a boolean based on the visibility desire. I played with the idea. Problem arises when the boolean for the last plot is false. In that case the legend box disappears entirely.

Again, I might be misunderstanding your suggestions. I'd appreciate you could add a code snippet along with your suggestion. This will be helpful given I'm still new to LV

0 Kudos
Message 4 of 7
(975 Views)

it looks like when you unselect the signal, the data being plotted does not have the first dataset to be plotted, this explains why the shift. 

 

As ity was suggested you can use a function called propery node( from the block diagram, right click on the plot) and select CREATE PROPERTY Node, 

then you can select the active plot and VISIBLE. 

 

0 Kudos
Message 5 of 7
(972 Views)
Solution
Accepted by topic author SudiptaDas

Your "active plot" is based on [i] and increments unconditionally. You might want to use an integer in a shift register (init with zero!) that only increments in the true case.

 

Now you can leave the FALSE case empty, except for wiring the integer across:

 

altenbach_0-1688580191742.png

 

Message 6 of 7
(967 Views)

Hello!
Thank you! It works perfectly. I've attached the .zip file of the project below. I've also added the Plot Legend Number property to keep the front end legend box consistent with the # of selected files. Here is a snap shot of the result:

SudiptaDas_0-1688585153791.png

 

0 Kudos
Message 7 of 7
(934 Views)