LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Can I add a second plot to an XY graph without having to re-draw the first?

Hi,

I'm trying to figure out a way to add a second plot (a linear fit between 2 cursors) to an XY graph without having to redraw the first plot (the underlying data). The reason this is important is that the first plot is typically hundreds of thousands of data points (or more), and it is slow to redraw. I would like the user to be able to move cursors around and dynamically do a linear fit to the underlying data in the range between the two cursors, with the line being drawn as the second plot.

My current program just wires both plots to the graph and re-draws both. This ends up being quite slow.

Ken
0 Kudos
Message 1 of 10
(5,676 Views)
You need to update all plots if you use a regular plot for the fit data.
 
IIn newer version of LabVIEW, you do NOT need to redraw the points, because you could draw the best fit line using the "plot images" property.
 
You should not graph hundreds of thousands of data points (or more) on an x-y graph. This make little sense since this probably exceeds the number of pixels on your graph.
 
Also make sure that your data points show as small unit dots of size=1. It is much more expensive to draw a fancy filled circle for example.
Message 2 of 10
(5,664 Views)

In case you can't use the property suggested by Altenbach, which probably is the best solution, try to use deferPanelUpdates property before updating the graph again.

BR
0 Kudos
Message 3 of 10
(5,654 Views)


@kal.... wrote:
try to use deferPanelUpdates property before updating the graph again.

That suggestion makes no sense. I don't see any timing difference with defer on or off. Typically, you want to defer updates if you need to write many properties in a row, which isn't the case here.

If I understand the question right, the primary data in the plot does not change, so we only need to write the graph terminal once and then never again. In the loop, check only the cursor position, take the subsets, and draw the line in the image overlay.

Are you really sure you need an x-y graph? This makes it much more difficult to extract the subset unless the values are sorted in x. Are they? If all points are spaced equally in x, you should use a waveform graph and set the ofset and increment via the axis property.

Message 4 of 10
(5,650 Views)


@altenbach wrote:


@kal.... wrote:
try to use deferPanelUpdates property before updating the graph again.

That suggestion makes no sense. I don't see any timing difference with defer on or off. Typically, you want to defer updates if you need to write many properties in a row, which isn't the case here.


Thanks to Altenbach, I stand corrected Smiley Happy
BR
0 Kudos
Message 5 of 10
(5,638 Views)
Thank you for your suggestion. I do have labview 8.2, so I think the "plot images" method you suggested should work.


@altenbach wrote:


If I understand the question right, the primary data in the plot does not change, so we only need to write the graph terminal once and then never again. In the loop, check only the cursor position, take the subsets, and draw the line in the image overlay.


Are you really sure you need an x-y graph? This makes it much more difficult to extract the subset unless the values are sorted in x. Are they? If all points are spaced equally in x, you should use a waveform graph and set the ofset and increment via the axis property.





You are understanding the problem correctly. The data does not change.

The values are sorted in X. I think I do need an XY graph, as the values are not spaced equally in x (they're close to equally spaced - the data comes from a fast camera which does not have a fixed frame rate but instead just outputs the images as fast as they can be processed). It's possible I could get by with a waveform graph, but it may not represent the data accurately enough.

Could you elaborate on your previous assertion that I should not be sending so many points to the XY graph? Implementing it differently seems like it could be enormously more complicated. Would you suggest that I manually remove data points based on the range of the X-axis before sending the data to the graph?

Thanks.

Ken
0 Kudos
Message 6 of 10
(5,637 Views)


@halvorka wrote:
Could you elaborate on your previous assertion that I should not be sending so many points to the XY graph? Implementing it differently seems like it could be enormously more complicated. Would you suggest that I manually remove data points based on the range of the X-axis before sending the data to the graph?

Maybe just something along the lines mentioned in the section "Fast Data Display with Decimation" at the following link:

http://zone.ni.com/devzone/cda/tut/p/id/3625

 

0 Kudos
Message 7 of 10
(5,628 Views)
Here's a quick draft how you could draw the regression line (LabVIEW 8.2). Modify as needed.
 

Message Edited by altenbach on 10-28-2007 12:51 PM

Download All
Message 8 of 10
(5,611 Views)
Wow, thanks. That will help out a lot! I haven't worked with pictures before, so your example vi will help ease the learning curve. Great post!

Ken
0 Kudos
Message 9 of 10
(5,600 Views)

@altenbach wrote:
 
Here's a quick draft how you could draw the regression line (LabVIEW 8.2). Modify as needed. [picture deleted to save space]
 

 


That's definitely cool, altenbach. I haven't worked with cursors in quite a while (since LV5, I think, and then only doing the simplest things). This one's going in my bookmarks.

 

Cameron

 

To err is human, but to really foul it up requires a computer.
The optimist believes we are in the best of all possible worlds - the pessimist fears this is true.
Profanity is the one language all programmers know best.
An expert is someone who has made all the possible mistakes.

To learn something about LabVIEW at no extra cost, work the online LabVIEW tutorial(s):

LabVIEW Unit 1 - Getting Started</ a>
Learn to Use LabVIEW with MyDAQ</ a>
0 Kudos
Message 10 of 10
(4,139 Views)