12-19-2008 01:19 PM
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?
Solved! Go to Solution.
12-19-2008 01:43 PM
12-19-2008 01:48 PM
12-19-2008 04:37 PM
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.
12-19-2008 05:29 PM - edited 12-19-2008 05:30 PM
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.
12-22-2008 09:27 AM - edited 12-22-2008 09:32 AM
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 memory. So 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 work. When 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 from? Maybe 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 saved? They are persistent, even when the vi is compiled. So in theory, it should be possible to do programmatically before I start filling the plot with data.
12-22-2008 11:03 AM - edited 12-22-2008 11:04 AM
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.
12-22-2008 04:59 PM
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