PDA

View Full Version : QwtPlot with multiple QwtPlotCurves all with different colors?



BettaUseYoNikes
15th July 2011, 15:59
I have a my own Plot class which has a function to create PlotCurves based upon x and y values that are passed in contained in vectors and a vector that holds index's of where each Curve ends and the next one begins. Since this is all happening in a for loop I need something like a ColorMap that I can grab a new color from every time for the pen color. I have been looking at QwtLinearColorMap but it doesn't seem to have the functionality I desire. I can access the amount of curves that are going to be plotted based upon the vector of index's size() function but I need a way to make each curve have a different color for any amount of curves.

FelixB
18th July 2011, 07:56
first: you can't have a unique color for any amount of curves. the RGB-format does not support more than 16,7 million colors ;)

You could use QColors methods darker(int factor) and lighter(int). You start with a color and in each loop you change it. I suggest switching between darker and lighter each loop otherwise the color would get completely white/black after some loops...
You could calculate colors on-the-fly based on the current loop-index, maybe combined with darker/lighter.
You could define a huge array which contains different QColors.