LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

predefine plot color palette

Solved!
Go to solution

Has anyone found a way to change the set of colors used by Labview to color plots in a waveform or xy graph?  By default the color sequence is white, red, green, blue, yellow, purple, orange...  I'm working on a waveform graph that plots a sequence of waveforms collected by daqmx.  The user can select which signals to measure and plot - e.g voltage, current, light intensity.  The user also defines a test sequence where they would like to watch the response of the DUT at each segment of the sequence. 

 

Based on other posts on this forum, I've figured out how to toggle between two plots in an xy graph to get the colors, but it seems like it should be much easier and more efficient to just change the preset colors that will be used by the waveform graph.   Why not just set the palette to something like red, white, red, white... and let the graph do its thing?

 

Any ideas?

0 Kudos
Message 1 of 8
(5,483 Views)
I'm not sure I understand what you mean by "toggle between two plots in an xy graph to get the colors". Can you better explain what visual effect you're trying to achieve? I also don't understand why setting the palette to alternating colors would help. You can set the plot colors programmatically. 
0 Kudos
Message 2 of 8
(5,475 Views)
I believe there is a property called "Plot Color Property". Create this property on your block diagram and change the color...using color box...
0 Kudos
Message 3 of 8
(5,473 Views)

hi, thanks for the replies.

 

I'm not on a machine with labview at the moment but I'll try to explain what I'm looking for.  Imagine a sine wave where all rising edges are red and falling edges are yellow.  You would see half of each wave in red and the rest would be yellow.  Repeat this any number of times to make a red and yellow sine wave.   So the color palette would be just red and yellow.  If there are 2 sine waves,  make the second one blue and purple.  Now the palette would have red, yellow, blue and purple.  Every time I collect and process a new segment, I need to make it a color different from the last segment.  So if the last one was red, then the new one should be made yellow. If I'm collecting 2 sine waves, then each segment will be an array of 2 waveforms and I will have to keep track of which array element gets which color.  At least it will always be in the same order, so its no big deal to keep track.

 

I have used the plot color property but it gets pretty slow once I have collected many segments - my processor eventually goes to 100% and my daqmx ai buffer overflows.  If I could define the color set before I start collecting data, then there would be no need for using property nodes to change the plot colors.

 

If that doesn't make sense, I'll try to post a picture.

0 Kudos
Message 4 of 8
(5,456 Views)

I think this may be what you are looking for.  Use NaN's and one waveform/array.  NaN's will not plot, so you can get gaps in the plot.  The attached example takes a sine wave and grabs the half cycles.  The risgin half cycle on one set of data is replaced by NaN's.  The falling cycle is replaced on a copy of the data.  Replace the array with these two arrays.  You now have 2 plots regardless of the number of cycles and the color will remain constant.

 

 

 

 


Message Edited by Matthew Kelton on 12-19-2008 06:30 PM
0 Kudos
Message 5 of 8
(5,445 Views)

Hi Matthew,

 

I've gotten this method to work with an xy plot (I can't use waveforms since my dt is a user variable).   Its much more processor efficient than using property nodes but I'm bothered by the 2x increase in memorySo far this is the best solution, but I can't help thinking that if I could change the color set that the graph pulls from when plotting, then I could just set the colors I want and let the plot do all the workWhen you create a plot indicator on a vi front panel and look at the plot legend, the color set is always the same - where does it come fromMaybe an ini file somewhere?

 

It just occurred to me - when you modify a plot, like change the axes or plot colors, where are the changes savedThey are persistent, even when the vi is compiledSo in theory, it should be possible to do programmatically before I start filling the plot with data.

Message Edited by gharris on 12-22-2008 09:32 AM
0 Kudos
Message 6 of 8
(5,401 Views)
Solution
Accepted by gharris

Depending on how much your plotting, the data memory may not be that big a hit.  If you are using an XY graph, then you don't even have to use twice the memory.  Just drop one NaN y data point between the two plots.  The only reason I had to do so many was because I was using the waveform graph and had to have it.

 

As best as I know, the colors are hard coded into LabVIEW.  When you change the colors in the development environment, the changes are stored within the control which is why you don't lose the information when you close and open the VI and/or LabVIEW.  However, when you compile your code into an EXE, any changes you make in the EXE will not stick between execution.   You can certainly change the colors using the property nodes, but unless you preallocate plots that aren't used, you'll have to do it with every new plot, as Active Plot is only available for a plot on the graph, not for a future plot.

 

Personally, I would stick with the 2 plots and just reduce what I did to one NaN.  It's a lot easier.

Message Edited by Matthew Kelton on 12-22-2008 12:04 PM
Message 7 of 8
(5,389 Views)

I changed my program to only put one NaN for the break in each trace - it works just fine.  This is definitely the most efficient solution I've tried.

 

Thanks for all your help,

George

0 Kudos
Message 8 of 8
(5,372 Views)