10-20-2009 04:32 PM
I want to continually replot an array using plotXY without incrementing the plot name. Is this possible?
Each time I call plotXY a new plot is created. For example, the first time plotXY is executed I get a plot labeled Plot1 (plot number 1). The second time I call plotXY I get a plot named Plot2 (plot number 2) and so on. But I want to plot the same array repeatedly as I add more data to it. And I want the plot name to be Plot1 every time.
I know I can change the name attribute to "Plot1" after calling plotXY. But I feel that somewhere in the graph's internals I am continually increasing the use of some resource. I'm going to be replotting the array several hundred thousand times so I don't want to run out of memory or something.
So my question is this, is there a way to re-initialize a graph to it's original state before executing plotXY?
Solved! Go to Solution.
10-20-2009 11:57 PM
Do not confuse the plot name and handle with the resources allocated to the graph. If you delete all plots from the graph with DeleteGraphPlot () prior to plotting a new curve, you should have "Plot 1" as the plot name, but you will get a continuosly increasing plot handle; this does not implies that you are summing up some additional resources every time you are plotting on the graph, the graph simply never reuses plot handles associated with deleted plots.
In your case you could additionally try some different approach:
10-21-2009 08:39 AM
Roberto,
Thank you for taking the time to consider and respond to my question.
There is an error in your response, I think. You said that using DeleteGraphPlot() prior to plotting a new curve results in the next plot being named "Plot 1". This is not true, I think. If it were true, I wouldn't have a problem. But PlotXY increments name and handle every time it's called. A CVI sample program demonstrates this (graphs.cws).
How does one keep track of plot handles when plotXY keeps incrementing them? What if I want to change attributes on a certain plot? Is it possible to keep track of which handle refers to which plot on the screen? I might have only one plot on a graph but it's handle might be 25. Good grief!
Also, you suggest using a chart instead of a graph. I wish I could do that because chart traces can be extended but graph plots cannot. But charts and graphs are fundamentally different, aren't they? I mean plotXY plots two arrays against each other. Strip Charts plot one array (y-axis) against time (x-axis). There's not a way to plot a array on the X axis a strip chart, is there?
What I really need (I think) is the ability to extend plot lines with incoming data. But that's not allowed for whatever reason.
Thanks again for your help.
10-21-2009 09:24 AM
You're right about plot names: I hadn't CVI installed on the machine I was using when responding to you so I couldn't check it.
With reference to plot handles, here you can find an interesting discussion about it. Your only option is to save in some variables all relevant plot handles returned from PlotXY.
With reference to your problem, have you considered option 2 in my previous post?
10-21-2009 11:17 AM
Roberto,
I considered your second suggestion. In that suggestion you propose extending the plot line incrementally by plotting new line segments as new information becomes available. My concern was that resources (computer memory?) might be depleted in plotting thousands of incremental line segments. But you said resource depletion is not a problem, I believe. If that's the case, then this "inch worm" approach is no problem. I can manage the array indexes and save the last value of the previous array as needed. So if the incremental graphing process doesn't become a memory leak then I'll be ok.
10-22-2009 11:21 AM
Hello querty,
It sounds as if you already have a solution for your problem, so this is just a clarification concerning the following points you had raised earlier:
How does one keep track of plot handles when plotXY keeps incrementing them? What if I want to change attributes on a certain plot? Is it possible to keep track of which handle refers to which plot on the screen? I might have only one plot on a graph but it's handle might be 25. Good grief!
Each time that you call a plotting function, the plot handle that will be created for that plot is returned to you as the return value of the function. Therefore, if you are continuously deleting a plot and replotting it, it is a similar matter of retaining the return value of the PlotXY function. That variable will hold the handle for the latest plot, which you can then use to set attributes on that plot, such as changing its label on the legend, for example.
Luis
10-22-2009 03:58 PM
LuiG,
I've decided to try the "inch worm" approach. That is, I'm going to incrementally extend my plot with new data using plotXY(). I presume this will also increment the plot handle infinately. I don't know what happens when the plot handle exceeds the size of an integer. I guess the only way to find out is to try it. Evidently, this is uncharted territory. Unfortunately, I risk doing a ton of work on my program only to find that it crashes once the plot handle gets too large.
10-23-2009 01:49 AM
Querty, I didn't realize that you have to deal with so many plots on a single graph!
As far as I can understand, either your process is very fast or it is very long: in any case it appears as if you are plotting data on every iteration. But no matter how big is your monitor ( ) 65000 plots on a single graph are a*big* amount of data: I wonder if the user is able to discriminate single plots! Since he's possibly not able, you could either plot some data every <n> (say every 5 or 6 iterations) or accumulate data for the some steps and plot them in a single PlotXY only once in a while. This will limit the number of plot handles generated, but moreover will reduce the screen output, which as you know is one of the slowest operations in a program.
10-23-2009 04:56 AM - edited 10-23-2009 05:00 AM
Forgive my last post I just realized that the plot handle is an int, so apparently the maximum number of plots that it can address is... 2147483647
I wonder if there is an actual limit on the number of plots that can be plotted on a graph: I found nothing on the online help and obviously I never reached such limit. Maybe Luis or some other person from NI can help us on that.
My suggestion about not plotting exactly all acquired points or not on every acquisition remains valid, though.
10-23-2009 12:13 PM
Roberto,
The program may not work out the way I plan. I'll likely hit a wall somewhere. But since I'm a novice and since I can't find a way to extend a line of XY data other than to incrementally add individual line segments (plots) then the number of plots could get large.
What I'm trying to do is create a stress-strain diagram. The X-axis represents strain (elongation of a material being stretched). The Y-axis represents stress (the force producing the stretch). The test ends when the sample breaks. It only takes a few minutes.
I plan to take 100 samples per second of X and Y data and plot all ten samples in an XY plot. These plots (line segments), connected end to end, will create a continuous line (I hope). A ten minute test will result in 60,000 data points (100 samples/sec x 60 sec/minute x 10 minutes). With each plot containing 100 samples there will be 600 plots (I think). If I forget to stop the program the number of plots will accumulate indefinately or until my computer explodes.
Ignorance is bliss! I'm sure I'll learn some valuable lessons from this exercise.
I'm not sure what difference the monitor size makes. CVI lets me create a graph with X-axis range of 0 to 60,000. But this may be more data points than dots per inch on the monitor. Hmmm... I haven't considered that.