需求来源:试验数据需要多轴对比。之前有过初步尝试还是大佬们写的好。
实现多Y轴、单X轴、X轴是时间轴、X轴range联动、rect之间的间距是0,每个图上有legend(这里有个疑问,每添加个rect在这个rect上添加graph,再添加legend,第一个rect上就有多个legend,其他rect上就只有一个。);
实现多Y轴、多X轴,x轴不联动。
频谱图,多Y轴,单X轴
关键代码如下,请大佬们多多指正:
//时域图
void MultiAxisWidget::recvRawData(int iRow, QString oStrLabel, QVector<double> adX, QVector<double> adY)
{
QCPAxisRect* poAxisRect = new QCPAxisRect(ui->plot);
poAxisRect->setAutoMargins(QCP::msNone);
poAxisRect->setMargins(QMargins(100, 0, 0, 0));
ui->plot->plotLayout()->addElement(iCntIndex, 0, poAxisRect);
QCPAxis* poAxisX = poAxisRect->axis(QCPAxis::atBottom);
QCPAxis* poAxisY = poAxisRect->axis(QCPAxis::atLeft);
poA