05-21-2015 05:44 AM
Hi,
The purpose is to plot a variable value over a certain period of time (if the selector is true). But the catch is that next time (after the target time reached or selector is true again), new plot of the same variable should be plotted from starting point (zero start time) with a different color. I attached a snapshot of my incomplete code here. Improvements and tips to change color in each run?
Thanks and regards,
Dave
05-21-2015 07:35 AM
You can do what you describe by working with the Properties of your Chart. One of them, History, holds the current Chart contents, and if an empty array is wired in, will clear the plot. Another allows you to set the Plot Color programmatically (how you choose it is up to you -- you could create an array with a series of colors, Red, Green, Blue, Yellow, and then cycle through them in a cylcic manner).
Bob Schor
05-21-2015 12:14 PM
Thanks. But XY graph doesn't have a history, dos it? Also, I need to have the earlier plots in the graph not erased, just addd a new plot to the old one (with the data coming via. the variable)??
- Dave
05-21-2015 02:05 PM
Sorry, I misunderstood what you wanted to do (and I saw a Waveform Chart in the picture you posted).
I'm still not complete sure I know what you want to do. Can you describe more completely your intent? Is it something like "Plot 2 traces of 500 points, then add a third, fourth, fifth trace of 500 points every 5 seconds, each of a different color"?
You are correct that my example was for a Chart that I made. But I've also made graphs, and you can color the different traces in much the same way via Property nodes.
Bob Schor
05-22-2015 03:20 AM
Yes, as u described the intention is "Plot #1 traces of 500 points, Plot #2 traces of 500 points, then add a third, fourth, fifth trace of 500 points. The case structure is wired to a control which can tell whether to draw plot #n or not , , the frequency of data is dependent on the while loop delay time which is set to 200ms for now. And yes, each plot shall have a different color. So, how exactly to do this?
Rgds,
Dave
05-22-2015 08:01 AM
You have to think carefully about exactly what you want to do. The reason I say this is you just added a "twist" by saying that you have N arrays of points and want to select which ones to plot.
Issues to consider: Suppose you have 5 plots and 5 colors, R, G, B, Y, O. If you choose to plot 1, 3, and 5, do you label them "1, 2, 3" with colors R, G, B, label them "1, 3, 5" with colors R, G, B, "1, 3, 5" with colors R, B, O? Do you want to plot all 5 all the time, but just make 2 and 4 "invisible"?
I trust you know how to plot multiple plots. [If not, write a really simple little VI with a For loop to generate, say, 5 data sets and wire them to a Waveform Graph until you get something that makes sense -- use LabVIEW Help as necessary]. Notice how the plots have different colors. Do you know about Property Nodes? Drop down a Property Node for the Graph, and explore what look like meaningful Properties (use LabVIEW Help to explain them). Once you think you understand one from its output, try setting it (by changing the Property from Write to Read) and see what happens.
I could simply "do this" for you, but you'll learn and understand what is going on (and it will "stick" with you) if you spend 10-15 minutes "playing" and seeing for yourself.
Bob Schor
05-25-2015 12:18 PM
Thanks. All the plots shall be shown (no need for any invisibility at the moment). My main challenge now is to change the color of new plot (e.g. plot#2) after plot#1 is drawn. And the same for plot#3 (the color should change to a new color) without any change on the plot#2 and plot#3. Appreciate te help.
Dave
05-25-2015 12:44 PM
Here's a hint. In LabVIEW, a Graph requires all of the points to be presented at once. In most cases, the time spent to produce the picture (i.e. the "graph") is fairly trivial, and almost always far shorter than the time to generate the data being plotted (which may come from collecting data over minutes).
Hence if you have a graph showing 3 sets of data, and now want to show 4 sets, there is usually no serious "cost" in simply overwriting the "graph-of-3" with a "graph-of-4". Try following the previous suggestions I made about creating some "example" code for yourself, generating several waveforms of (say) random data and plotting them. Once you have a plot of, say, 4 graphs, what changes do you need to make to have it plot 5 graphs?
Read what I wrote about Property Nodes (of the Graph). If you don't know what a Property Node is, use LabVIEW Help. Drop a Property Node for your Graph, look at the list of properties that are available, try to examine some that seem "interesting". Change some to Read and try setting them to see how it affects your Graph. Teach yourself how do solve your problem.
Bob Schor