LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

plot multiple curves in a single graph

I need to write a program that draws several curves on the same x-y graph. All the curves have the same x values. The hard part is that the number of curves is not known in advance. The person running the finished program can choose 1 or 100. All the examples I can find seem to be based on knowing how many charts there are and wiring up an array of clusters. It is not obvious to me how to do this dynamically.

[If you are by any chance a Genplot user, I'm looking for the LabVIEW equivalent of the "overlay" command.]
0 Kudos
Message 1 of 4
(3,098 Views)
The array of clusters can be dynamically build, so when the user chooses how many curves to display you start a for loop or while loop to scan the datas, build the clusters and group them in the array to pass to the XY graph.
Roberto


Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 2 of 4
(3,098 Views)
Hi Gnues-

Just to expound on this issue a little further, I found a great description already present in Developer Exchange. The answer was posted by user CraigGraham - kudos to Craig.

"Assuming you're using the X-Y graph (the word "multiplot" means little to
me) then each dataset is a cluster of the X array and Y array for that
dataset. To put several datasets on the graph you make an array of these
clusters. This should be very clear in the context help for the X-Y plot
terminal.

To add spectra you simply append it to the array of spectra already in the
plot. The brute force and simplest to understand approach would be to use a
local to retrieve all the data that's currently in the plot as an array,
append the new plot to the end and write it all back to the plot,
either to
its terminal or via another local. More elegant would be to buffer your
array of plots internally within the program and have an array of Booleans
allowing you to selectively show/hide plots, either by omitting datasets
when writing them to the graph or, to maintain consistency in plot styles,
writing an empty element to the array in place of hidden datasets, but if
this is meaningless to you then the first suggestion is perfectly adequate."

ben schulte
national instruments
0 Kudos
Message 3 of 4
(3,098 Views)
HI
JUST TRY THIS
IT IS A SAMPLE VBCODE
0 Kudos
Message 4 of 4
(3,098 Views)