QCustomPlot Discussion and Comments

Gradient Fill for Channel Fill from zero point to data pointReturn to overview

I would like to to fill the plot channels with gradient brush, I was able to set the QBrush to a particular colour but in order to plot the gradient, I will need to provide the start and stop axis of the data point to fill. How do I get the start and end points of the data points on qcustom plot.

The effect I want to achieve is to create a brighter fill as the data point gets higher, similar to this picture from the web.


Thank for the advice!

I'm not entirely sure which points you exactly mean but maybe this helps: To get the pixel value of a coordinate in the plot, you can use the coordToPixel method on the respective axis. So for example to get the y pixel of the y axis at coordinate 2.0, call


So maybe the two points for the gradient are given by customPlot->yAxis->coordToPixel(0) and customPlot->yAxis->coordToPixel(maxDataValue) where maxDataValue is the maximum (y) data value you have in the graph?