QCustomPlot Discussion and Comments

Questions about colormapReturn to overview

Hello, I am using colormap to realize the PRPD map in the field of partial discharge. I have two questions to ask how to achieve it:
1. I customized the color scale, the defined range is (1-6), I want to display the background color (black) when there is no data, instead of displaying the color with the smallest color scale bar.
2. I want to add a sine wave reference curve on the colormap and overlay it on the colormap. I tried addgraph and found that the curve was covered.
Thank you

1. Only set the gradient of colorscale when there is no data, do not set the gradient of colormap, and then set when there is data

colorMap>setGradient(QCPColorGradient::gpPolar);

QCPColorScale *colorScale = new QCPColorScale(customPlot);
colorScale->setGradient(QCPColorGradient::gpPolar);
colorMap->setColorScale(colorScale);

2. Note that graph should be added to qcustomplot after colormap

//translated from chinese by admin

The first one is a bit wrong, fix it

QCPColorScale *colorScale = new QCPColorScale(customPlot);
colorMap->setColorScale(colorScale);
disconnect(colorScale, SIGNAL(gradientChanged(QCPColorGradient)), colorMap, SLOT(setGradient(QCPColorGradient)));  // Disconnect signal slot
colorScale->setGradient(QCPColorGradient::gpPolar);
connect(colorScale, SIGNAL(gradientChanged(QCPColorGradient)), colorMap, SLOT(setGradient(QCPColorGradient)));   // Re-establish the signal slot connection

//translated from chinese by admin

Sorry, I didn’t make it clear that the first one, my data is some scattered points, and not all pixels of colormap are filled. In the implementation, the points without data will be automatically filled with the color of the minimum value of the colorscale bar. I hope it is displayed as a background color. What should I do with this?

//translated from chinese by admin

If there is no data point, set the transparency to 0. colormap->data()->setAlpha()

//translated from chinese by admin

Solved, thank you for your answer.

//translated from chinese by admin