Showing results for 
Search instead for 
Did you mean: 

Strange behaviour of plot (plot legend)

Go to solution

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:


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: 


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

(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
0 Kudos
Message 3 of 7

"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

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
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:




Message 6 of 7

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:



0 Kudos
Message 7 of 7