LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to color the NaN Gap in the graph??

Hi, can u do me a favour??? did any one know how to plot out a graph with gap, but the gap is in diferrent color.
as i know the gap can be plot by input the value NaN. any idea how to color it????
Thank~
 
Terry
0 Kudos
Message 1 of 7
(3,383 Views)
NaN should plot as a gap.  That is the idea of it so you don't graph no data or invalid data.  So, I don't think you can color it.
Matthew Fitzsimons

Certified LabVIEW Architect
LabVIEW 6.1 ... 2013, LVOOP, GOOP, TestStand, DAQ, and Vison
0 Kudos
Message 2 of 7
(3,372 Views)
If you want two colors on the same line, you have to overlay two traces.  The trivial method is to create as many data sets as you want colors, then set each data set to NaN where you don't want it shown.  This nicely overlays things, but results in using a lot of data.  If you only have a couple of thousand points, this isn't a problem.  If you have 20 million, it is.

An alternate method is to split you data into as many arrays as you have contiguous color segments.  In your case, this is three sections.  Plot the data as three separate traces, with appropriate colors.  To get the X values right, you will need to use either the waveform datatype or the t0, dt, Y cluster data format.  You will also need to uncheck the ignore timestamp property of the graph (right click on the graph, not the axis, after you have wired the data to it and select the option), then reformat the X axis as you wish.  You may want to duplicate the end points of each segment so that the lines actually touch.

One hidden gotcha.  If you increase the number of graphs you are using, you will need to set the colors programmatically using graph property nodes or you will end up with the default colors.  You cannot set the properties of a trace if the trace does not exist.  You can get around this by always using the same number of traces, but have zero length Y arrays in the ones you are not using.
0 Kudos
Message 3 of 7
(3,357 Views)

I m not really understand what you talking about, could you send me the example for me to have a clear picture. What i mean is the data gap should draw in one line with the data, but with diferrent color. i may have few thoudsand data to plot isit posible...???

Thank~

TerrySmiley Very Happy

0 Kudos
Message 4 of 7
(3,329 Views)
Here you go.  LabVIEW version 7.0.  I used waveform datatypes. For another example using the cluster data type and for methods of dealing with large sets of data (100s of millions of points), check out the tutorial Managing Large Data Sets in LabVIEW.  Look at the bottom loop in the memory store and browse examples. Note that this is an advanced tutorial.
0 Kudos
Message 5 of 7
(3,314 Views)

Well, if there is a gap, you cannot really plot a line graph in the gap, because there is no data. However, you could make a second plot with "Inf" values in the gap and NaN elsewhere, then use "File baseline:-infinity". This will basically color the background of the gap differently.

If you have LabVIEW 8.0 or higher, you can also use direct image drawing commands on graphs. Here you could simply draw a colord box over the gaps.

0 Kudos
Message 6 of 7
(3,303 Views)
"direct image drawing commands on graphs"
do u mean the "Plot Images" property of XYGraph??
0 Kudos
Message 7 of 7
(3,278 Views)