From Saturday, Nov 23rd 7:00 PM CST - Sunday, Nov 24th 7:45 AM CST, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Clear graph plots in Labwindows

There is a clear plot function for strip charts and digital graphs, but none for graphs. I've tried using the DeleteGraphPlot (han, cid, plothandle, VAL_IMMEDIATE_DRAW); function, but it only seems to erase the last dot plotted. How to I clear a graph to start over?
0 Kudos
Message 1 of 11
(5,994 Views)
Just pass -1 as the plot handle.

Also, if you're going to be re-plotting more data on the graph, immediately following, you should pass VAL_DELAYED_DRAW instead of VAL_IMMEDIATE_DRAW in order to minimize flashiness.

Luis
0 Kudos
Message 2 of 11
(5,987 Views)
Wow. That was easy. Thanks also for the tips on minimizing screen flash.
0 Kudos
Message 3 of 11
(5,964 Views)
Hi Luis:

You were helpful on the issue above. Works fine. Thank you.

Now can you help me make the attach graph look more attractive? It's graphing 20 current readings every 10 seconds flowing through solar cells. I'm using the "small dot" to plot the current values, and a open circle to plot temperature. The current (I) plots look terrible. There is a current jump up at 70 deg C on the left side of the graph, and the current lines disconnect and do not follow the jump up. It seems that a line is needed for continuity. Below is the lines of code which plot current.

        for (i=0; i<20; i++) {   // Generate and plot the data for the right Y axis.
            SetCtrlAttribute (tabPanelRun, TAB_RUN_GRAPH, ATTR_ACTIVE_YAXIS, VAL_RIGHT_YAXIS);
            currPlotHandle = PlotPoint (tabPanelRun, TAB_RUN_GRAPH, x, yy[i], VAL_SIMPLE_DOT, colors[i]);           
        }
        x += 0.20;


Do you have any comments on how to improve the appearance?

Thanks,
Doug Wendelboe



0 Kudos
Message 4 of 11
(5,958 Views)
I'm not completely sure how you'd like your graph to look. For example, would you like to connect the current measurements within each trace? If you don't, and you really just want to plot very many individual current points, I'm not sure how it could improved. It really depends on the data layout, and its cosmetic appeal is somewhat subjective anyway. Maybe if you can mock up a screenshot of what you'd like it to look, I might be able to have a better idea of what you're looking for.

Something that might help, would be if you reduce the x-axis time range, so that the points aren't so closely bunched together (when you use a 120 minute range, a 10 second gap is probably less that one graph pixel). If you had more space between consecutive samples, that might allow you to use a point style other than VAL_SIMPLE_DOT. You could also experiment with the ATTR_ANTI_ALIASED_PLOTS attribute, although that probably won't help with points as much as it does with plot lines.

By the way, for this type of application, shouldn't you be using a strip chart instead of a graph? Not that that would necessarily solve the cosmetic problems, but it seems more intuitive, and is probably more efficient than maintaining thousands and thousands of individual point plots in the graph.

Luis
0 Kudos
Message 5 of 11
(5,942 Views)
Interesting ideas. I originally started out with using a strip chart, but I never found a good way to have two axes. The plots did look better on a strip chart. I have wanted to overplot temperature (scale 20-180 deg C) and current (scale 0-5A). I looked into laying one stripchart on top of another, and making the background of the top chart transparent. Couldn't get the trace of both to show up. There still seemed to be something opaque between the two charts.

On the graph I currently have, both temperature are scaled properly. I guess I would like to improve it with line connected points rather than dots so that they stand out better. The reason I am using a graph is that technician operators will monitor this screen during a production run. They soon learn what a "good" run looks like and what a run with problems looks like.

Thanks again for your input,
Doug
0 Kudos
Message 6 of 11
(5,937 Views)
Doug,

Which version of CVI are you using? Before CVI 8.5, you couldn't use a second y-axis on a strip chart. But if you're using 8.5 or 8.5.1, do let me know if you're having troube using the second y-axis.

If you're using a version that is older than that, and you have to use a graph as a result, then what I would do if I were you, in order to connect the plot points, would be to maintain a history of the data in memory (20 large arrays, for example), and with each 10 sec. tick I would append the latest data point to each array. I would then clear the graph and re-plot each array, using all the data points that you had appended so far on each array, using PlotY or PlotWaveform. That way, you have much more flexibility in choosing a plot style.

A simpler alternative to that would be to use PlotLine instead of PlotPoint, and pass it the previous point and the current point, for that trace. That way you still end up connecting your points, and you don't have to preserve all the data points for each trace. Just the previous point for each trace.

Also, if you have CVI 8.0 or later, you should know that you can configure your x-axis to use a relative time scale, which allows you to display labels in the form MM:SS, for example.

Luis
0 Kudos
Message 7 of 11
(5,917 Views)

This doesn't explain how to delete (DeleteGraphPlot)  all the points when you use "PlotPoint". Yes, -1 will clear the graph panel but it will also clear the rest of the data that one does not want cleared. So, is there a way to clear all the values for "PlotPoint" or must one use a different plot method?

0 Kudos
Message 8 of 11
(5,214 Views)

There isn't a "selective clear" command for graphs: either you delete a single plot by passing its handle or you delete all the existing plots on the graph.

 

You may want to store in an array all handles for plots you want to delete. Alternatively you could place 2 graphs one on top of the other, the topmost one with transparent background, and plot all relevant traces on one of them and dynamic data on the other, which you can then clear entirely without loosing other useful data.



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 9 of 11
(5,202 Views)

All points in the  PlotPoint functions do not all delete when you pass the plot handel in DeletePlot. I've thought about making two PlotPoint graphs with the same data array  one transparent to hide the previous data. But that seemed kind of cheesy. But if that's the only way than it's the only way. To the end user it will look deleted.

0 Kudos
Message 10 of 11
(5,198 Views)