重绘后如何重置qcustomplot中的x和y轴(Qt)

时间:2015-11-11 16:59:42

标签: c++ qt qcustomplot

我正在尝试裁剪数据,并仅重新绘制图形的选定部分,但在重新绘制后,x轴仍然具有相同的值,而我的图形从(0,0)开始而不是(cropped_starting_value_x, Y)。 如何重置X轴的值?我已经尝试过rescaleaxes,但它不起作用。 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();

非常感谢各种帮助!

1 个答案:

答案 0 :(得分:0)

您应该使用此方法:

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

(文件here