03-22-2013 04:42 AM
Hi RavenFan,
My plotting code works perfectly well as a stand alone code. If you open my zipped file, it is called "Plotting VI Stand Alone.vi".
By running the code, the user is prompted to select any number of files (from 1 to 13 by holding ctrl down) and it makes two XY plots. One is Y vs. X, the other is Y vs. X with Y error bars.
I have included in the zipped file 13 simple data files that you can try. The error bars come out exactly as I want them. The error bars on each curve match the color of the corresponding curve.
Now, I took my stand alone code and made it into a sub VI. This is called "Plotting VI As SubVI.vi" in my zipped file attached below. I call this sub VI in my "Main VI.vi" and when I run
it, it works fine with 1 to 2 files, maybe 3 or 4, but then when you select 7 or 8 files, all of a suddent I get 1077 error and the error bars don't come out right. The colors don't match.
Why is this happening?
03-22-2013 10:34 AM
Your upper graph only has 13 plots defined, but if you select more than 7 traces at once, you will have more than than and the active plots cannot be found. By the time you call the subVI, these don't exist. Once you have more plots than currently actually exist, you'll get an error. The second time you run it with the same number, the error no longer occurs.
Simplest would be to plot dummy data with the correct number of plots to a local variable before calling the subVI, for example.
03-22-2013 10:44 AM - edited 03-22-2013 10:45 AM
Try something like this. There are probably other solutions...
Both of your plots seem to have 13 plots by default, so the error does not occur for less than seven plots. Another possibility would be to pick a higher upper default limit and save the VI. Still, you never know how many plots there will be.
03-22-2013 11:21 AM
Alternatively, you could write the data to a value property of the graph inside the subVI (you already have the reference) before each inner loop. This way you don't even need the outputs of the subVI. 😄
03-22-2013 12:33 PM
Thank you very much Altenbach!
However, I am not understaning fully why the upper graph has only 13 graphs defined. This is just the number of elements in the point style array that determines the loop iteration count.
You suggestion solved the problem, but I don't know exactly what it did. Thanks a bunch anyway!!
03-22-2013 12:47 PM
If you select 13 files, the property loop for the upper graph will iterate 26 times, because all autoindexing input arrays are 2x concatenated versions of the arrays for the other graph. When this happens the first time, the graph still contains a smaller number of plots, so the properties cannot be applied.
(This is a somewhat annoying behavior and I intend to post an idea in the ideas exchange how this could be improved. Stay tuned.)
03-22-2013 01:15 PM
@altenbach wrote:
I(This is a somewhat annoying behavior and I intend to post an idea in the ideas exchange how this could be improved. Stay tuned.)