简体   繁体   中英

How to reset x and y axis in qcustomplot after replotting (Qt)

I am trying to crop my data, and replot only a selected part of the graph, but after the replot, the x axis still has the same values, and my graph starts at (0,0) instead of (cropped_starting_value_x, y). How can I reset the values of the X axis? I've already tryed rescaleaxes, but it's not working. Here I only have values from around 19 seconds.

QCPGraph *mainGraph = Customplott[0]->addGraph();
QCPGraph *SecondaryGraph = Customplott[0]->addGraph();
//QCPGraph *TertiaryGraph = Customplott[Number]->addGraph();

//mainGraph->setAdaptiveSampling(true);
mainGraph->setData(Time_temp, Measured_temp);
mainGraph->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssNone, QPen(Qt::red), QBrush(Qt::white), 3));
mainGraph->setPen(QPen(Qt::blue)); // Magic only happens, when line width == 1

SecondaryGraph->setData(Time_temp, Output_temp);
SecondaryGraph->setPen(QPen(Qt::red));

Customplott[0]->setObjectName("YawRate");
Customplott[0]->xAxis->setLabel("Time [s]");
Customplott[0]->yAxis->setLabel("Yaw Rate");


/* rescale axes according to graph's data */
Customplott[0]->rescaleAxes();
mainGraph->rescaleAxes();
SecondaryGraph->rescaleAxes(true);

Customplott[0]->replot();

Every kind of help is highly appreciated!

You should use this method:

Customplott[0]->xAxis->setRange(minX, maxX);

(documentation here )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM