I don't know how to add yAxis2 to a qcustomplot. The way i am using qcustomplot, I don't specify xAxis or yAxis. But i need to plot another graph on yAxis2. I will appreciate any inputs.
我不知道如何将yAxis2添加到qcustomplot中。我使用qcustomplot的方式,我不指定xAxis或yAxis。但我需要在yAxis2中绘制另一个图。如有任何意见,我将不胜感激。
ui->widget->addGraph();
ui->widget->graph()->setData(xVal,yVal);
ui->widget->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom | QCP::iSelectAxes |
QCP::iSelectLegend | QCP::iSelectPlottables);
ui->widget->graph()->setName(QString::number(yVal[0]));
ui->widget->legend->setVisible(true);
QFont legendFont = font();
legendFont.setPointSize(10);
ui->widget->legend->setFont(legendFont);
ui->widget->legend->setSelectedFont(legendFont);
ui->widget->rescaleAxes();
ui->widget->replot();
1 个解决方案
#1
0
ui->widget->yAxis2->setVisible(true);
ui->widget->xAxis2->setVisible(true);
ui->widget->yAxis2->scaleRange(-1,1);
ui->widget->addGraph(ui->widget->xAxis2,ui->widget->yAxis2);
ui->widget->graph(1)->setData(xVal,yVal);
#1
0
ui->widget->yAxis2->setVisible(true);
ui->widget->xAxis2->setVisible(true);
ui->widget->yAxis2->scaleRange(-1,1);
ui->widget->addGraph(ui->widget->xAxis2,ui->widget->yAxis2);
ui->widget->graph(1)->setData(xVal,yVal);