QCustomPlot Discussion and Comments

colormap-how to control the colorbar's rangeReturn to overview

// add a color scale:
	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)
	colorMap->setColorScale(colorScale); // associate the color map with the color scale
	//colorScale->axis()->setLabel("Magnetic Field Strength");

which function can control the colorbar's range?? is it auto to filling the colorbar?

http://www.qcustomplot.com/documentation/classQCPColorScale.html#abe88633003a26d1e756aa74984587fef

Hi

you have to connect to the QCPColorScale signal dataRangeChanged(QCPRange) like:

connect(colorScale, SIGNAL(dataRangeChanged(QCPRange)), this, SLOT(onColorRangeChanged(QCPRange)));

your slot should do something like this:

void myclass::onColorRangeChanged(const QCPRange &range)
{
if (range.lower<0) {
QCPRange r(0,range.upper);
colorScale->setDataRange(r);
}
}

You can scale it with

QCPRange r(0,range.upper);
colorScale->setDataRange(r);

regards
uwe