# LabVIEW

cancel
Showing results for
Did you mean:

Solved!
Go to solution

## Strange behaviour of plot (plot legend)

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:

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.

Message 1 of 7
(418 Views)

## Re: Strange behaviour of plot (plot legend)

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

Message 2 of 7
(386 Views)

## Re: Strange behaviour of plot (plot legend)

Sorry!
Zip file attached!

Message 3 of 7
(382 Views)

## Re: Strange behaviour of plot (plot legend)

"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

Message 4 of 7
(369 Views)

## Re: Strange behaviour of plot (plot legend)

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.

Message 5 of 7
(366 Views)
Solution

## Re: Strange behaviour of plot (plot legend)

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
(361 Views)

## Re: Strange behaviour of plot (plot legend)

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:

Message 7 of 7
(328 Views)