QCustomPlot Discussion and Comments

Use only QCPColorScale widgetReturn to overview

Hello,

In my app, I use QCustomPlot to represent multiple curves in a graph. I would also add an independent component of the plot to customize the colors to associate with each curve. In this component I would like to be able to use a color scale (QCPColorScale) to assign a color to a graph.

Each curve of my graph has a property value "V" and I would like the QCPColorScale to have the interval [min-max] with:
- min : the smallest value "V" associated with a curve
- max : the largest value "V" associated with a curve

I would then use this QCPColorScale to associate with each curve the corresponding color.

To do that, I need to get a color for a value from the QCPColorScale. But I have the impression that it is not possible? There is no function getColor (double value) for example?

Is it mandatory to use a QCPColorMap with QCPColorScale? If so, how to recover from the color map the color associated with a value?

Thank you

Seems like i need separate QCPColorScale too :)
Maybe this is it: (code copied from colormap demo and edited)

 
    QCPColorScale *colorScale = new QCPColorScale(customPlot);
    customPlot->plotLayout()->addElement(0, 1, colorScale); // add it to the right of the main axis rect
    colorScale->setType(QCPAxis::atRight); // scale shall be vertical bar with tick/axis labels right (actually atRight is already the default)
    colorScale->axis()->setLabel("Magnetic Field Strength");

    colorScale->setGradient(QCPColorGradient::gpJet);
    colorScale->setDataRange(QCPRange(0,1));

    customPlot->plotLayout()->remove(customPlot->axisRect());
    customPlot->replot();