LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

plotting two arrays on the same chart

Hi, 

 

I have some data which I would like to plot on a chart but I would also like to plot the middle section of the data in a different colour. Imagine a bell curve where the middle peak is to be a different colour so the outlier sections.

What i have done so far is to get the two regions into different arrays, now I need to combine them into the same array to plot together. However I don't know how I sync them. At the moment when I plot them the middle section is plotted from index 0 on the x axis when it needs to be shifted by an offset. I have thought about placing it into the correct index however this will result in the ends being plotted as zeroes which is unwanted. 

 

Thanks 

Stephen

Labview 14.0, Labview 12.0
CLAD
Mechanical Engineering Student
0 Kudos
Message 1 of 7
(4,729 Views)

Common pitfall: rigth click on the graph and disable 'ignore timestamp'

or

convert all datapoints to xy data and plot it with a xy-graph or a mixed-graph

 

more help if you attach your example vi  with example data 🙂

 

Greetings from Germany
Henrik

LV since v3.1

“ground” is a convenient fantasy

'˙˙˙˙uıɐƃɐ lɐıp puɐ °06 ǝuoɥd ɹnoʎ uɹnʇ ǝsɐǝld 'ʎɹɐuıƃɐɯı sı pǝlɐıp ǝʌɐɥ noʎ ɹǝqɯnu ǝɥʇ'


0 Kudos
Message 2 of 7
(4,715 Views)

Hi , thanks for your help. Unfortunately the data doesn't have a timestamp. the frequency is know and that what I'm using to plot. I'm not using the absolute time just relative time - the date was captured at 1000hz. 

As for the xy graph solution, how would i go about creating a coloum of integers for the x axis.

 

thanks

Stephen

Labview 14.0, Labview 12.0
CLAD
Mechanical Engineering Student
0 Kudos
Message 3 of 7
(4,712 Views)
The waveform graph also accepts a cluster of an initial x value, a delta x value, and a 2D array of y data. The graph interprets the y data as points on the graph and increments the x index by delta x, starting at the initial x value. This data type is useful for displaying multiple signals that are sampled at the same regular rate.
-Looks this method might work and use the initial X value to shift the graph :http://zone.ni.com/reference/en-XX/help/371361M-01/lvconcepts/types_of_graphs_and_charts/#Waveform_G...
Thanks
uday
Message 4 of 7
(4,710 Views)

The "trick" to plotting a set of data using different colors for different sets of points is to realize that (a) you can't do it in LabVIEW, as a plot has a "defined color" for the entire set of points, so (b) you need to "cheat" a little and plot it twice.

 

Let's assume you have an array "Red Data" of Dbls (you need to use Floats for this, so if your data are integers, you'll need to copy them to a Dbl array.  Make a copy of Red Data, call it Green Data.  Now set Red Data to plot using Red points, and Green Data to plot using Green Points.  If you plot them both, the points will sit "on top of" each other, and whichever is plotted last will show up, not what you want.

 

So now you need to "disappear" the Red Data points that should be Green, and the Green Data Points that should be Red.  Make a third, Boolean, array called "Red", and set it True if you want a Red point, and False if you want a Green point.  Now, in a For loop, process all three Arrays.  If Red is True, set the Green Data point to NaN (Not a Number) and the Red Data point to itself (i.e. "preserve it), while if Red is False, set the Red Data point to NaN and Green Data to itself.  Now plot both Red Data and Green Data.  The NaN data points don't plot, so each position gets either a Red Data or Green Data point, as you specify.

 

Bob Schor

0 Kudos
Message 5 of 7
(4,698 Views)

One annoying part of two plots with NaN is the gap you have if you just sort the points to 2 colors (see top graph)

so I would suggest easy mod to just add colored points , see the lower solution.

or share one point in both plots.... or simply overlay ( play with the plot properties)

 

How many ideas have already been posted to motivate NI to have a graph with a color ramp plot?

 

2colorplot.png

Greetings from Germany
Henrik

LV since v3.1

“ground” is a convenient fantasy

'˙˙˙˙uıɐƃɐ lɐıp puɐ °06 ǝuoɥd ɹnoʎ uɹnʇ ǝsɐǝld 'ʎɹɐuıƃɐɯı sı pǝlɐıp ǝʌɐɥ noʎ ɹǝqɯnu ǝɥʇ'


0 Kudos
Message 6 of 7
(4,647 Views)

Thank you all for the suggestions. Creating two arrays and then bundling into a waveforem cluster seems to work the best. 

 

Thanks

Stephen

Labview 14.0, Labview 12.0
CLAD
Mechanical Engineering Student
0 Kudos
Message 7 of 7
(4,636 Views)