QCustomPlot Discussion and Comments

Rescale not work on constant dataflowReturn to overview

I can not use rescale function. In two signal graph, that function puts one signal in upper bound and another one in lower bound. In this situation both signal can not seen clearly.

I have made my own rescale function accordig rescale fuction.

            if(ui->auto_1_pushButton->isChecked())
            {
                ui->plot_1->yAxis->rescale();

                low_range = ui->plot_1->yAxis->range().lower;
                up_range = ui->plot_1->yAxis->range().upper;
                hysteresis = (up_range - low_range) / 20.0;

                ui->plot_1->yAxis->setRange(low_range - hysteresis,up_range + hysteresis);
            }

First recsale the value axis and than extend it accordign to the hysterisis.

Everything works fine in analog signals in real time plot. When I try it with constant data, rescale function not work and my graphs ranges continously growing. How can overcome this problem? rescale function not return any result according to operating result.

If the plot only contains a graph with constant data, the rescale function can't find an appropriate range to set to. So all it does is preserve the current range size and center the graph. So the way you have implemented your hysteresis now just keeps adding "hysteresis" to the range size, and that keeps getting used by the next rescale call and so on.

I recommend you implement your hysteresis differently. Take the current range, then do the rescale, and then scale to currentRange+(newRange-currentRange)*0.05. This way, if currentRange==newRange, nothing will change.

Thanks DerManu for your help.

My main problem with rescale function is not to squeeze data to clearly visable when two graphs in plot. The plot with higher values had been put upper limit of plot and the other one in lower limit. So, they can not be seen clearly.

Your method only slow down the rescale function with magnitute of multiplier. At the end result is the same as rescale function. I can use this methot in my feature works.

I have extended rescale function ranges with the code below.

if(ui->auto_1_pushButton->isChecked())
{
       old_range_1 = ui->plot_1->yAxis->range();

        ui->plot_1->yAxis->rescale();

        if(old_range_1 != ui->plot_1->yAxis->range())
        {
              low_range = ui->plot_1->yAxis->range().lower;
              up_range = ui->plot_1->yAxis->range().upper;
              hysteris = (up_range - low_range) * 0.05;

              ui->plot_1->yAxis->setRange(low_range - hysteris,up_range + hysteris);
         }
}