//将图例设置成横排显示
ui->customplot->legend->addElement(0,1,ui->customplot->legend->item(1));
ui->customplot->legend->addElement(0,2,ui->customplot->legend->item(2));
//图例置于底部
ui->customplot->legend->setMargins(QMargins(320,1,1,1));
int count = ui->customplot->plotLayout()->rowCount();
ui->customplot->plotLayout()->addElement(count,0, ui->customplot->legend);
ui->customplot->plotLayout()->setRowStretchFactor(count, 0.0001); //设置行的伸展因子
ui->customplot->axisRect()->insetLayout()->setInsetAlignment(0, Qt::AlignRight|Qt::AlignTop);