LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

access plot colors programmatically

Hi all,

When plotting multiple plots on the same axes, Labview automatically assigns each plot a different colour.
How can I programmatically access this colour sequence (an array?) and set it with an array of colours I choose?

Regards,
Jamie
Using Labview version 8.0
0 Kudos
Message 1 of 30
(4,084 Views)
Hi Jamie,

the following code should work:


Ton


Message Edited by TonP on 02-11-2008 07:45 AM
Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
0 Kudos
Message 2 of 30
(4,074 Views)

Use a property node of the graph with two items: (1) active plot (2) plot color.

For example the code shown in the image would change the first three plots to green, red, and yellow respectively by autoindexing over an array of 3 colorbox constants.



Message Edited by altenbach on 02-10-2008 10:51 PM
0 Kudos
Message 3 of 30
(4,068 Views)
Use Plot color property node, as shown in the attached vi
0 Kudos
Message 4 of 30
(4,066 Views)
Hi,
My VI is more flexible in terms of number of plots, see attached example.
When increase the number of plots between runs, errors occur in assigning the colour array.
How can I dynamically program the chart to be ready for any number of plots?
Jamie
Using Labview version 8.0
0 Kudos
Message 5 of 30
(4,026 Views)
Hi Jamie,

easy solution: first plot the data, then color them! Because: you cannot color more plots than are plotted in the chart...
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 30
(4,022 Views)
how many plots can there be maximum?
 
if you create a "big" array of colors, and let "dimension size" control how many times the loop iterates, you should be fine
 
you could also create a sub-array with the proper length of colors according to dimension, and let the auto-indexing tunnel set the number of iterations (remove dimension to N), thatway, you can never get "out of bounds" if you have more plots than colors, the drawback however is that the plots above the number of colors in your "big" array will not be assigned speciffic colors.
0 Kudos
Message 7 of 30
(4,019 Views)
Thanks for the help all.
I've tried Gerd's solution and also one of my own by initialising the history with the right number of plots.
These all work for the small examples provided.
However, when I put them into my larger program of multiple VIs and chart data acquired from a queue, I still get the same errors with invalid active plot inputs.
I really have no idea why the errors occur in the larger program am at a bit of a loss.
Jamie


Using Labview version 8.0
0 Kudos
Message 8 of 30
(3,996 Views)
Hi Jamie,

so where's the difference between the "small solution" presented here and your "larger program"?
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 9 of 30
(3,984 Views)
Hi Jamie,

I recommend hooking up the Simple Error Handler.vi to your error cluster to pinpoint exactly where the error is occuring in your main VI.  You can then probe the inputs to those property nodes;  that should shed some light on the subject.
Eric V
National Instruments
Applications Engineer
Certified LabVIEW Associate Developer


"I'm a Ramblin' Wreck from Georgia Tech and a helluva (NI Applications) Engineer!"
0 Kudos
Message 10 of 30
(3,959 Views)