QCustomPlot Discussion and Comments

Automatic scaling along the Y-axisReturn to overview

Hi. How to do automatic scaling on the Y-axis based on local maximum and minimum, visible on the screen? Sorry for my English.

If you only have one rect in your QCustomPlot, and you only want the Y-axis to be scale, this can be done with something like this :


I have 2 rect. It doesn't work. I can use ui->customPlot->yAxis->setRange(low,high); ,but for this I need to know the visible high and low.

What I do is get those values before doing the graph. For example my data is in QVector<double> linenb. I do.

double minrangeLine = *std::min_element(linenb.begin(),linenb.end());
double maxrangeLine = *std::max_element(linenb.begin(),linenb.end());

Then I use this minrange and maxrange to scale acccordingly.


In my code rescale() work fine.
You need call customPlot->replot() after rescale().
And you need call graph->setKeyAxis() and graph->setValueAxis() when you create graph.

If you want use axis->setRange(minmaxRange), you need call minmaxRange = graph->getKeyRange() or minmaxRange = graph->getValueRange().

Sorry for my English))