04-29-2012 01:29 AM
I want to plot:
Time Amp
1 2
2 4
3 9
How do I get the legend to automatically say Amp, instead of Plot 0? I went to property node -> legend and I don't see any option
that would read the "column" header and label the legend accordingly.
In my example, the X array (Time) and Y array (Amp) are fed into Bundle which is then fed to the XY Graph input. The X array (1,2,3) and Y array (2,4,9)
obviously carry no information about their respective column names (Time, Amp). So, the legend must read this information separately, but I don't know
how to feed this information to the plot legend.
Solved! Go to Solution.
04-29-2012 02:22 AM - edited 04-29-2012 02:23 AM
You simply need a property node for "plot.name". You have only one plot, so the following is sufficient (of course you would replace the string diagram constant with whatever you read from the column header in the file)
(If you have several plots, you would do it in a loop, setting the active plot from the iteration terminal, first, then writing the name)
Since this is an xy graph, I would actually hide the legend and simply label the two axes according to their header. This can be done in a similar way with property nodes. See if you can figure it out. 😉
(Of course if the labels never change, enter them once manually and they will be saved with the VI. No code needed.)
04-29-2012 02:29 AM
Thank you very much!
04-29-2012 02:56 AM
While we're on this topic, suppose I had a 3rd column which are error bars for Amp. At each X (Time) value the Y (Amp) could have a different error. Is there an easy way to plot these error bars?
04-29-2012 11:33 AM - edited 04-29-2012 11:35 AM
04-29-2012 12:21 PM
Thank you GerdW.
I was able to plot two curves on the same plot with the error bars. However, I was not able to program the legend to appropriate reflect the two plots.
It only shows Plot 0, while I have two curves on the same plot called AMP and AMP2.
Just like the XY Graph, I tried to get Property Node Plot name, but I didn't see that (and tried other Legend related properties) in the 2D error plot. lik
The data coming from my tester has the format (X1, Y1, ERR1), (X2, Y2, ERR2), and so on in separate files. The number of files can vary from 1 to 6 or seven.
What I would like is to be able to open the folder that contains these files, select those files that I want to plot, and be able to plot them, and have the plot
display the legend as AMP1, AMP2, AMP3, for cuve 1, curve 2, curve 3, etc. If I choose 4 files, then it should display 4 curves with legend reflecting this fact.
Again, the number can vary. Also, the four curves should have different colors and markers.
My idea is to put the files I select in an array, and create a for loop with N = size of this array, and put the "Plot Helper" part of the 2D Error Plot inside this for loop
with a shift register. This will connect the "Plot Helper" portion of the 2D Error Plot in a series and once the loop is finished, all the curves will be shown on the 2D Error Plot
outside of the for loop. I think this should work. The part that I need help with is how to dynamically change the legend. Am I going about this the right way?
I assume 2D error plot is not as powerful as XY Graph, but perhaps sufficient for my purpose.
04-29-2012 01:08 PM
I figured this out. After exploring more, the legend can be changed by Create -> Property Node -> Plot Specific -> Error Bar name
04-29-2012 01:25 PM
Hi GerdW,
I'm close to getting this done, but unfortunately, the legend doesn't automatically increase with the number of plots.
I am plotting two curves, Amp1 and Amp2, by my left says Amp2, then Plot0. Please see the attached VI and the test file I have created.
Thanks!
04-30-2012 06:26 PM
Hi murchak,
You really are almost there- you just need to update the Active Plot for each iteration of your For Loop. The end result should look something like this:
05-01-2012 04:31 PM
Hi JaymeW,
Thank you for your reply! As much as I like to read and learn more about LabVIEW, I'm very busy with work right now so I know I lack
the fundamentals. How do you get the 2D Error Bar (strict) property shown inside the for loop? What is a "strict?"