LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how can i dynamically vary the color of one graph line

I was looking on the developer zone and noticed several people are looking for a way to change the color of one graph line. Simplest case I would like to know: a graph is running, then you press a button and from that point on the color of the graph changes, but doesnt change the old data line color. THis way the line will consist of different colors.

The property node changes the whole line, and the line is always just one color. It should be possible to make the line consist of different color sections, anyone know how?
0 Kudos
Message 1 of 11
(5,463 Views)
You cannot have multiple colors for a single line, but you can still get the effect you want.

Simply compose it of multiple lines each from an identical array and where parts with the wrong color are NAN.

See example.
Message 2 of 11
(5,463 Views)
> The property node changes the whole line, and the line is always just
> one color. It should be possible to make the line consist of different
> color sections, anyone know how?

Actually, plots have colors, but points do not. Plots have colors for
the trace and the interior and points, but do not support different
colors on different ranges. To do this, you simply use more than one
plot. If you need two colors, have two plots of different color or
style. For an XY graph, place the points in the appropriate plot. If
it is waveform graph, you might find it useful to place NaNs in the
other points to pick up the plot pen.

Greg McKaskle
Message 3 of 11
(5,463 Views)
Thank you so much, you're a genius!
0 Kudos
Message 4 of 11
(5,463 Views)
Indeed it is useful as mentioned by the others to send the data to multiple overlapping plots. It then looks as if the plot changes color, but the other colors don't show up because they receive NaN
0 Kudos
Message 5 of 11
(5,463 Views)
Use for example 100 for the frequency factor in the previous program
0 Kudos
Message 6 of 11
(5,463 Views)
gefiliciteerd Douwe,

This little vi manages to allready consume up to 90% cpu time on my not so slow computer. Even though it does the job, there must be better ways to program this. Like storing them in seperate arrays and writing them to different overlapping xy graphs. I think that any data that is not being worked on should be taken out of a loop.
0 Kudos
Message 7 of 11
(5,463 Views)
Oh just make the loop time longer (it was 20msec), as in the attached program (100msec), then only 5% cpu time. For my data acquisition it works fine because the time constant is 300msec, so less than 2% cpu time

But I think Labview should write a utility that allows a conditional multicolor plot. I've noticed others looking for this also

Douwe
0 Kudos
Message 8 of 11
(5,463 Views)
I agree. I am one of them. I made an application that heavily relies on an xy graph and I don't like that for every bit of new data I have to redraw the whole thing unless I do the "invisible 2nd graph trick"
Aart-Jan
0 Kudos
Message 9 of 11
(5,463 Views)
The application is actually not as slow as it seemed, i had some settings set wrong (anti aliasing in plot, and some functions in advanced, when you right click on the graph)

Especially unchecking the anti-aliasing makes it much faster

Also, just plotting point and not a line, or alternatively, changing the interpolation makes it faster.

Anyway, the attached files do not rely on processor so much anymore, see for yourself

😄
0 Kudos
Message 10 of 11
(5,463 Views)