LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Multicoloured XY Graph

Is there any way to change the colour of parts of an XY Graph. An example of what I would like to do is draw a sine curve with the positive values a different colour to the negative values. I have tried splitting my data and superimposing 2 different coloured graphs but because I need to use continuous lines I get lines joining non adjacent parts of the curve. My application is more complex than a sine curve, and looks considerably worse than the effect with a sine curve.

Any pointers would be appreciated.

Niel.
0 Kudos
Message 1 of 6
(3,466 Views)
The only way that I see to do this is to take 2 XY graphs and put the bottom of the top graph to the top of the bottom graph. Make the top graph one color, and only show positive numbers; make the bottom graph negative numbers, and have the graph a different color. Then wire the data to both graphs. It should look continuous like you want.

Mark
0 Kudos
Message 2 of 6
(3,466 Views)
Very restrictive, a pain in the arse to set up and assumes all of the data
changes colour at the same Y value, which may only be true in the simplified
case quoted as an example.

You can get around the problem of lines joining adjacent sections by having
each section in a separate plot. So you get your dataset, feed it into a
loop. In that loop you take points and put them into new arrays. Every time
the "changeover" condition is met, you start a new array. The last point of
one array is duplicated as the first point of the next. You then end up
with, say, an array of individual segments that you can plot, and
programmatically set all the even numbered segments to one colour and the
odd numbered segments to another. Okay there may be a couple of hundred
segm
ents rather than two, but this is no big deal and should be pretty
simple to code.

markwysong wrote in message
news:506500000005000000DD1D0000-984882144000@quiq.com...
> The only way that I see to do this is to take 2 XY graphs and put the
> bottom of the top graph to the top of the bottom graph. Make the top
> graph one color, and only show positive numbers; make the bottom graph
> negative numbers, and have the graph a different color. Then wire the
> data to both graphs. It should look continuous like you want.
>
> Mark
0 Kudos
Message 4 of 6
(3,466 Views)
That is the way to go. You just have to make the last point of one branch to
be the first of the next branch to insure the continuity.

Jean-Pierre Drolet
Scientech R&D


"Niel" a écrit dans le message news:
506500000008000000C5170000-984882144000@quiq.com...
> Is there any way to change the colour of parts of an XY Graph. An
> example of what I would like to do is draw a sine curve with the
> positive values a different colour to the negative values. I have
> tried splitting my data and superimposing 2 different coloured graphs
> but because I need to use continuous lines I get lines joining non
> adjacent parts of the curve. My application is more complex than a
> sine curve, and looks considerably worse than the effect with a sine
> curve.

>
> Any pointers would be appreciated.
>
> Niel.
0 Kudos
Message 3 of 6
(3,466 Views)
Tip: if a data point in an array is NaN, then it won't be plotted on he
graph.

NaN stands for Not a Number; just type the letters NaN into a numeric
constant.

So you can define 2 plots, one red for positive, another blue for
negative.
In the positive array replace the negative values by NaN.
In the negative array replace the positive values by NaN.
Join the 2 arrays & plot.

It's a good, clean look!

Mark

Niel wrote:
>
> Is there any way to change the colour of parts of an XY Graph. An
> example of what I would like to do is draw a sine curve with the
> positive values a different colour to the negative values. I have
> tried splitting my data and superimposing 2 different coloured graphs
> but because I need to use continuous lines I get lines joinin
g non
> adjacent parts of the curve. My application is more complex than a
> sine curve, and looks considerably worse than the effect with a sine
> curve.
Message 5 of 6
(3,466 Views)
Mark, Thanks, the NaN approach works great.

Niel.
0 Kudos
Message 6 of 6
(3,466 Views)