在QcustomPlot中,给横纵坐标添加箭头的方法
//在末尾添加箭头 customPlot->xAxis->setUpperEnding(QCPLineEnding::esSpikeArrow); customPlot->yAxis->setUpperEnding(QCPLineEnding::esSpikeArrow);
怎么给图画虚线的方法
//设置虚线QPen linesPen(Qt::red,1,Qt::DashLine); line = new QCPItemStraightLine(customPlot); line->setPen(linesPen); line->setClipToAxisRect(true); line->point1->setCoords(0,0); line->point2->setCoords(0,0); //虚线平行于x轴 line->point1->setCoords(customPlot->xAxis->range().lower,0.2); line->point2->setCoords(customPlot->xAxis->range().upper,0.2);
文本框的设置
//创建文本对象QCPItemText *text = new QCPItemText(customPlot);//设置文本坐标解析方式 text->position->setType(QCPItemPosition::ptAxisRectRatio);//设置位置在矩形区域的位置 text->setPositionAlignment(Qt::AlignLeft | Qt::AlignBottom);//设置位置 text->position->setCoords(0.1,0.90);//设置文本内容 text->setText("你好"); text->setTextAlignment(Qt::AlignLeft);//设置颜色 text->setColor(QColor(Qt::red));//设置页边距 text->setPadding(QMargins(1,1,1,1));
步长的设置
//创建对象QSharedPointer<QCPAxisTickerFixed> intTicker( new QCPAxisTickerFixed );//设置步长精度 intTicker->setTickStep(0.1);//设置y轴步长 customPlot->yAxis->setTicker(intTicker);
设置坐标轴为矩形及坐标的刻度样式
ui->customPlot->xAxis2->setVisible(true);//x2轴可见 ui->customPlot->yAxis2->setVisible(true);//y2轴可见 ui->customPlot->xAxis2->setTicks(false);//x2刻度不可见 ui->customPlot->yAxis2->setTicks(false);//y2刻度不可见 ui->customPlot->yAxis->setSubTicks(false);//y1子刻度不可见