From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

add point to scatter plot each time a button is pressed

Hi folks,

 

 

Apologies if this has been answered elsewhere, I am new to LabVIEW and trying to get an experiment up-and-running quickly! Smiley Happy

 

I was wondering if anybody would have general pointers or code examples on how to create a 2D scatter plot, to which a data point is added each time a button is pressed.

 

I am measuring a gauge pressure and a force (from a load cell). I would like the scatter plot to add another data point each time I press a button, so that a history of my datapoints is shown. It would also be quite nice is this plot could then be exported as a .jpg using another button, but this is not critical. 

 

A seperate button would also be available to clear the scatter plot.

 

 

My current thinking is that this can be done by 'adding to an array', - presumably the chart would refresh each time an element was added to the array, but I am struggling a little bit with how to do this.

 

If anybody has any suggestions, I would be very grateful for them.

 

 

Many thanks,

 

Euan

0 Kudos
Message 1 of 2
(2,301 Views)

Hi Euan,

 

If you want to have your data shown in real time (and I'm assuming you do) then you'll need to use a Waveform Chart. The chart is able to update itself each time a value is written to it.

 

The event structure is your friend here: you can write a case to update the chart each time a button is pressed. You can also create cases for the other situations you mentioned (clear chart, export jpg etc.)

 

If you don't care about the chart updating in real time then you can use your idea of updating an array and then use a Waveform Graph to plot the datapoints at the end of your program.

 

Take a look at the LabVIEW Basics course and the Examples for info on how to implement the event structure. If you run into any problems just post your VI and we'll see if we can't help you fix them.

 

-CC

----------------------------------------------------------------------------------------------------------------------------
"If anyone needs me, I'll be in the Angry Dome!"


0 Kudos
Message 2 of 2
(2,281 Views)