Showing results for 
Search instead for 
Did you mean: 

How to dynamically add a plot to a mixed signal graph

Go to solution

I have a mixed signal graph where I am plotting a signal vs. a time axis. I am trying to dynamically add a second plot to this graph against the same time axis (with a different Y scale) but when I build a 2D array and try to wire it into the graph (using a local variable) I get a dimension mismatch error. I know for sure I have done this in the past (wired arrays with different sizes to a same MSG) without any problems but today for some reason I can't seem to solve this. 


Am I missing something?

Download All
0 Kudos
Message 1 of 5

You're writing the multiple plots to a local variable of the graph instead of the indicator terminal itself. The indicator terminal adapts to 1D/2D data to show single or multiple plots, but the local variable can't do this.

Somewhere you need to wire a 2D array to the actual terminal and this should fix your problem. You should really use the terminal instead of the local var anyways.


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'

Message 2 of 5

Thanks James,


the problem is I write to this graph in two different parts of the program, first a single plot and then only if the user presses a button I add the second plot (not always since calculating the second plot is very time-consuming). 


I have tried to put the indicator into the main while loop of the VI but then the graph is redrawn with every iteration, and I need to define an output for the graph for every case of the case loop that's inside the while loop (if I just set it to "default if unwired" it will be cleared). 


I have another graph in the same program where I first send a 2D array (2x1D arrays) and then when the user presses a button I add a third 1D array to that 2D array and plot it by writing to a local variable, but I guess in this case the problem isn't adding a new array to a 2D array but changing the dimension from 1D to 2D. 

0 Kudos
Message 3 of 5
Accepted by topic author thehun

Yeah, you're probably writing a 1D array somewhere that's causing it to only accept 1D. To fix your above problem, just put a Build Array node in wherever you have a 1D array and it will just be a 2D array with only one row of data.

 To add a plot to your current plots, your screenshot above should work once the plot knows to accept 2D arrays.


Reading from a local variable, changing something, and then writing to it again can lead to a lot of issues down the line. Race conditions are a pain in the butt, so getting rid of that type of stuff is good to do early on. I haven't seen the rest of your code, so I don't know how you're handling this, but just keep that in mind as you're adding to your software.


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'

Message 4 of 5

Yep, that did the trick, thanks again! Smiley Happy

0 Kudos
Message 5 of 5