Plot different curves with different colors
Hello,
I'm using Qwt to plot more than one curve, but I would like to have different color for each curve. I don't know why, but even if I change the value of the color using an increment my curves get always the same color. I checked the color mapping and I saw the values for each color, then I tried to start with Qt::Black (value 2) and use a counter to increment to the next color. Example below:
Code:
graph
[iGraphCounter
].
setAxes(QwtPlot::xBottom,
QwtPlot::yLeft+iGraphCounter
);
graph[iGraphCounter].setTitle(object->legend.c_str());
graph
[iGraphCounter
].
setRenderHint(QwtPlotItem::RenderAntialiased);
graph
[iGraphCounter
].
setLegendAttribute(QwtPlotCurve::LegendShowLine,
true);
graph
[iGraphCounter
].
setPen(QColor(Qt
::black+iColorCounter
));
But when I run the software all my curves are black. The increment for the graph handler is ok, the increment for the new y-axis is ok and the increment for the color is ok. I checked with a break point and my variable is incrementing fine and changing the value, but somehow the color doesn't change.
Can anyone help me? I have no idea about what it's wrong. It would be nice some help. :)
Thanks in advance
Best Regards
Re: Plot different curves with different colors
Code:
graph
[iGraphCounter
].
setPen( QColor( Qt
::GlobalColor( Qt
::black+iColorCounter
) ) );
Re: Plot different curves with different colors
Hello Spitfire,
I found a solution today using the RGB values, but thanks anyways, good to know, because your solution is shorter. Using RGB I had to create a color mapping.
Thanks.