示例1

  1. 包含两个折线图
  2. 折线图颜色,和X轴的闭合填充颜色
  3. 坐标轴自动缩放

void MainWindow::setupSimpleDemo(QCustomPlot *customPlot)
{demoName = "Simple Demo";
//  添加2个折线图// add two new graphs and set their look:customPlot->addGraph();
//   设置画笔就是线的颜色customPlot->graph(0)->setPen(QPen(Qt::blue)); // line color blue for first graph//设置画刷就会用画刷填充与X的轴闭合区域customPlot->graph(0)->setBrush(QBrush(QColor(0, 0, 255, 20))); // first graph will be filled with translucent bluecustomPlot->addGraph();customPlot->graph(1)->setPen(QPen(Qt::red)); // line color red for second graph// generate some points of data (y0 for first, y1 for second graph):QVector<double> x(251), y0(251), y1(251);for (int i=0; i<251; ++i){x[i] = i;y0[i] = qExp(-i/150.0)*qCos(i/10.0); // exponentially decaying cosiney1[i] = qExp(-i/150.0);              // exponential envelope}// configure right and top axis to show ticks but no labels:// 一个轴矩形包含4个轴,上下左右,设置可以显示的坐标轴 (see QCPAxisRect::setupFullAxesBox for a quicker method to do this)customPlot->xAxis2->setVisible(true);customPlot->xAxis2->setTickLabels(false);customPlot->yAxis2->setVisible(true);customPlot->yAxis2->setTickLabels(false);// 自动跳帧坐标轴 make left and bottom axes always transfer their ranges to right and top axes:connect(customPlot->xAxis, SIGNAL(rangeChanged(QCPRange)), customPlot->xAxis2, SLOT(setRange(QCPRange)));connect(customPlot->yAxis, SIGNAL(rangeChanged(QCPRange)), customPlot->yAxis2, SLOT(setRange(QCPRange)));// 给折线图添加数据 pass data points to graphs:customPlot->graph(0)->setData(x, y0);customPlot->graph(1)->setData(x, y1);//  自适应坐标轴// let the ranges scale themselves so graph 0 fits perfectly in the visible area:customPlot->graph(0)->rescaleAxes();// same thing for graph 1, but only enlarge ranges (in case graph 1 is smaller than graph 0):customPlot->graph(1)->rescaleAxes(true);// Note: we could have also just called customPlot->rescaleAxes(); instead// Allow user to drag axis ranges with mouse, zoom with mouse wheel and select graphs by clicking://允许缩放、拖动、plot可以选着customPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom | QCP::iSelectPlottables);
}

示例2

  1. 添加多个曲线

  2. 使用了误差线

  3. 坐标州的旋转、刻度显示格式、精度

  4. 连个折线图的闭合区域填充


void MainWindow::setupSincScatterDemo(QCustomPlot *customPlot)
{demoName = "Sinc Scatter Demo";//显示图例customPlot->legend->setVisible(true);
//  设置图例字体和大小customPlot->legend->setFont(QFont("Helvetica",9));// set locale to english, so we get english decimal separator:customPlot->setLocale(QLocale(QLocale::English, QLocale::UnitedKingdom));// add confidence band graphs:
//  添加第0个customPlot->addGraph();QPen pen;pen.setStyle(Qt::DotLine);pen.setWidth(1);pen.setColor(QColor(180,180,180));customPlot->graph(0)->setName("Confidence Band 68%");//这个名字也就是图例显示的内容customPlot->graph(0)->setPen(pen);customPlot->graph(0)->setBrush(QBrush(QColor(255,50,30,20)));
//添加第1个customPlot->addGraph();
//  第一个图例不显示
//  customPlot->legend->removeItem(customPlot->legend->itemCount()-1); // don't show two confidence band graphs in legendcustomPlot->graph(1)->setPen(pen);
//  设置折线图0和折线图1之间的闭合区域填充customPlot->graph(0)->setChannelFillGraph(customPlot->graph(1));//    添加第2个// add theory curve graph:customPlot->addGraph();pen.setStyle(Qt::DashLine);pen.setWidth(2);pen.setColor(Qt::red);customPlot->graph(2)->setPen(pen);customPlot->graph(2)->setName("Theory Curve");//添加第3个折线图// add data point graph:customPlot->addGraph();customPlot->graph(3)->setPen(QPen(Qt::blue));customPlot->graph(3)->setName("Measurement");customPlot->graph(3)->setLineStyle(QCPGraph::lsNone);customPlot->graph(3)->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssCross, 4));// add error bars:QCPErrorBars *errorBars = new QCPErrorBars(customPlot->xAxis, customPlot->yAxis);errorBars->setName("error bars");//不显示图例errorBars->removeFromLegend();errorBars->setAntialiased(false);//绑定 error barba 参数数据就是第3个线图errorBars->setDataPlottable(customPlot->graph(3));errorBars->setPen(QPen(QColor(255,180,180)));// 生成数据generate ideal sinc curve data and some randomly perturbed data for scatter plot:QVector<double> x0(250), y0(250);QVector<double> yConfUpper(250), yConfLower(250);for (int i=0; i<250; ++i){x0[i] = (i/249.0-0.5)*30+0.01; // by adding a small offset we make sure not do divide by zero in next code liney0[i] = qSin(x0[i])/x0[i]; // sinc functionyConfUpper[i] = y0[i]+0.15;yConfLower[i] = y0[i]-0.15;x0[i] *= 1000;}QVector<double> x1(50), y1(50), y1err(50);for (int i=0; i<50; ++i){// generate a gaussian distributed random number:double tmp1 = rand()/(double)RAND_MAX;double tmp2 = rand()/(double)RAND_MAX;double r = qSqrt(-2*qLn(tmp1))*qCos(2*M_PI*tmp2); // box-muller transform for gaussian distribution// set y1 to value of y0 plus a random gaussian pertubation:x1[i] = (i/50.0-0.5)*30+0.25;y1[i] = qSin(x1[i])/x1[i]+r*0.15;x1[i] *= 1000;y1err[i] = 0.15;}y1[25]=1;y1err[25]=0.5;// 设置数据给Plot   pass data to graphs and let QCustomPlot determine the axes ranges so the whole thing is visible:customPlot->graph(0)->setData(x0, yConfUpper);customPlot->graph(1)->setData(x0, yConfLower);customPlot->graph(2)->setData(x0, y0);//给误差bar设置误差值customPlot->graph(3)->setData(x1, y1);errorBars->setData(y1err);customPlot->graph(0)->rescaleAxes(true);
//  customPlot->graph(1)->rescaleAxes(true);
//  customPlot->graph(2)->rescaleAxes(true);
//  customPlot->graph(3)->rescaleAxes(true);// setup look of bottom tick labels:
//  x轴的刻度旋转30°customPlot->xAxis->setTickLabelRotation(30);customPlot->xAxis->ticker()->setTickCount(10);//坐标轴数字显示格式customPlot->xAxis->setNumberFormat("ebc");//保留小数位数/精度customPlot->xAxis->setNumberPrecision(1);customPlot->yAxis->setRange(-1,3);//移动坐标轴customPlot->xAxis->moveRange(-10);customPlot->yAxis->moveRange(0);// make top right axes clones of bottom left axes. Looks prettier:customPlot->axisRect()->setupFullAxesBox();
}

示例3

1.各种图的散点风格示例

void MainWindow::setupScatterStyleDemo(QCustomPlot *customPlot)
{demoName = "Scatter Style Demo";customPlot->legend->setVisible(true);customPlot->legend->setFont(QFont("Helvetica", 9));customPlot->legend->setRowSpacing(-3);QVector<QCPScatterStyle::ScatterShape> shapes;shapes << QCPScatterStyle::ssCross;shapes << QCPScatterStyle::ssPlus;shapes << QCPScatterStyle::ssCircle;shapes << QCPScatterStyle::ssDisc;shapes << QCPScatterStyle::ssSquare;shapes << QCPScatterStyle::ssDiamond;shapes << QCPScatterStyle::ssStar;shapes << QCPScatterStyle::ssTriangle;shapes << QCPScatterStyle::ssTriangleInverted;shapes << QCPScatterStyle::ssCrossSquare;shapes << QCPScatterStyle::ssPlusSquare;shapes << QCPScatterStyle::ssCrossCircle;shapes << QCPScatterStyle::ssPlusCircle;shapes << QCPScatterStyle::ssPeace;shapes << QCPScatterStyle::ssCustom;QPen pen;// add graphs with different scatter styles:for (int i=0; i<shapes.size(); ++i){customPlot->addGraph();pen.setColor(QColor(qSin(i*0.3)*100+100, qSin(i*0.6+0.7)*100+100, qSin(i*0.4+0.6)*100+100));// generate data:QVector<double> x(10), y(10);for (int k=0; k<10; ++k){x[k] = k/10.0 * 4*3.14 + 0.01;y[k] = 7*qSin(x[k])/x[k] + (shapes.size()-i)*5;}customPlot->graph()->setData(x, y);customPlot->graph()->rescaleAxes(true);customPlot->graph()->setPen(pen);customPlot->graph()->setName(QCPScatterStyle::staticMetaObject.enumerator(QCPScatterStyle::staticMetaObject.indexOfEnumerator("ScatterShape")).valueToKey(shapes.at(i)));customPlot->graph()->setLineStyle(QCPGraph::lsLine);// set scatter style:if (shapes.at(i) != QCPScatterStyle::ssCustom){customPlot->graph()->setScatterStyle(QCPScatterStyle(shapes.at(i), 10));}else{QPainterPath customScatterPath;for (int i=0; i<3; ++i)customScatterPath.cubicTo(qCos(2*M_PI*i/3.0)*9, qSin(2*M_PI*i/3.0)*9, qCos(2*M_PI*(i+0.9)/3.0)*9, qSin(2*M_PI*(i+0.9)/3.0)*9, 0, 0);customPlot->graph()->setScatterStyle(QCPScatterStyle(customScatterPath, QPen(Qt::black, 0), QColor(40, 70, 255, 50), 10));}}// 重新调节坐标轴set blank axis lines:customPlot->rescaleAxes(true);customPlot->xAxis->setTicks(false);customPlot->yAxis->setTicks(false);customPlot->xAxis->setTickLabels(false);customPlot->yAxis->setTickLabels(false);// make top right axes clones of bottom left axes:customPlot->axisRect()->setupFullAxesBox();
}

折线图风格示例

可选风格

 enum LineStyle { lsNone        ///< data points are not connected with any lines (e.g. data only represented///< with symbols according to the scatter style, see \ref setScatterStyle),lsLine       ///< data points are connected by a straight line,lsStepLeft   ///< line is drawn as steps where the step height is the value of the left data point,lsStepRight  ///< line is drawn as steps where the step height is the value of the right data point,lsStepCenter ///< line is drawn as steps where the step is in between two data points,lsImpulse    ///< each data point is represented by a line parallel to the value axis, which reaches from the data point to the zero-value-line};Q_ENUMS(LineStyle)

示例代码

void MainWindow::setupLineStyleDemo(QCustomPlot *customPlot)
{demoName = "Line Style Demo";customPlot->legend->setVisible(true);customPlot->legend->setFont(QFont("Helvetica", 9));QPen pen;QStringList lineNames;lineNames << "lsNone" << "lsLine" << "lsStepLeft" << "lsStepRight" << "lsStepCenter" << "lsImpulse";// add graphs with different line styles:for (int i=QCPGraph::lsNone; i<=QCPGraph::lsImpulse; ++i){customPlot->addGraph();pen.setColor(QColor(qSin(i*1+1.2)*80+80, qSin(i*0.3+0)*80+80, qSin(i*0.3+1.5)*80+80));customPlot->graph()->setPen(pen);customPlot->graph()->setName(lineNames.at(i-QCPGraph::lsNone));customPlot->graph()->setLineStyle((QCPGraph::LineStyle)i);customPlot->graph()->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssCircle, 5));// generate data:QVector<double> x(15), y(15);for (int j=0; j<15; ++j){x[j] = j/15.0 * 5*3.14 + 0.01;y[j] = 7*qSin(x[j])/x[j] - (i-QCPGraph::lsNone)*5 + (QCPGraph::lsImpulse)*5 + 2;}customPlot->graph()->setData(x, y);customPlot->graph()->rescaleAxes(true);}// zoom out a bit:customPlot->yAxis->scaleRange(1.1, customPlot->yAxis->range().center());customPlot->xAxis->scaleRange(1.1, customPlot->xAxis->range().center());// set blank axis lines:customPlot->xAxis->setTicks(false);customPlot->yAxis->setTicks(true);customPlot->xAxis->setTickLabels(false);customPlot->yAxis->setTickLabels(true);// make top right axes clones of bottom left axes:customPlot->axisRect()->setupFullAxesBox();
}

给散点添加图片作为散点样式 示例

void MainWindow::setupScatterPixmapDemo(QCustomPlot *customPlot)
{demoName = "Scatter Pixmap Demo";//设置背景图customPlot->axisRect()->setBackground(QPixmap("./solarpanels.jpg"));customPlot->addGraph();customPlot->graph()->setLineStyle(QCPGraph::lsLine);QPen pen;pen.setColor(QColor(255, 200, 20, 200));pen.setStyle(Qt::DashLine);pen.setWidthF(2.5);customPlot->graph(0)->setPen(pen);customPlot->graph(0)->setBrush(QBrush(QColor(255,200,20,70)));//设置散点为一个图片,同时图例也会使用这个图customPlot->graph(0)->setScatterStyle(QCPScatterStyle(QPixmap("./sun.png")));// set graph name, will show up in legend next to icon:customPlot->graph(0)->setName("Data from Photovoltaic\nenergy barometer 2011");// set data:QVector<double> year, value;year  << 2005 << 2006 << 2007 << 2008  << 2009  << 2010 << 2011;value << 2.17 << 3.42 << 4.94 << 10.38 << 15.86 << 29.33 << 52.1;customPlot->graph(0)->setData(year, value);// set title of plot:customPlot->plotLayout()->insertRow(0);customPlot->plotLayout()->addElement(0, 0, new QCPTextElement(customPlot, "Regenerative Energies", QFont("sans", 12, QFont::Bold)));// axis configurations:customPlot->xAxis->setLabel("Year");customPlot->yAxis->setLabel("Installed Gigawatts of\nphotovoltaic in the European Union");customPlot->xAxis2->setVisible(true);customPlot->yAxis2->setVisible(true);customPlot->xAxis2->setTickLabels(false);customPlot->yAxis2->setTickLabels(false);customPlot->xAxis2->setTicks(false);customPlot->yAxis2->setTicks(false);customPlot->xAxis2->setSubTicks(false);customPlot->yAxis2->setSubTicks(false);customPlot->xAxis->setRange(2004.5, 2011.5);customPlot->yAxis->setRange(0, 52);// setup legend:customPlot->legend->setFont(QFont(font().family(), 7));
//  设置图例中ico的大小customPlot->legend->setIconSize(50, 20);customPlot->legend->setVisible(true);//设置图例的显示位置customPlot->axisRect()->insetLayout()->setInsetAlignment(0, Qt::AlignLeft | Qt::AlignTop);
}

使用时间刻度类 示例

  1. 创建1个对象
  2. 设置时间格式
  3. 设置刻度对象给指定轴

void MainWindow::setupDateDemo(QCustomPlot *customPlot)
{demoName = "Date Demo";// set locale to english, so we get english month names:customPlot->setLocale(QLocale(QLocale::English, QLocale::UnitedKingdom));// seconds of current time, we'll use it as starting point in time for data:double now = QDateTime::currentDateTime().toMSecsSinceEpoch()/1000.0;srand(8); // set the random seed, so we always get the same random data// create multiple graphs:for (int gi=0; gi<5; ++gi){customPlot->addGraph();customPlot->graph(gi)->setName(QString("G%1").arg(gi));QColor color(20+200/4.0*gi,70*(1.6-gi/4.0), 150, 150);customPlot->graph()->setLineStyle(QCPGraph::lsLine);customPlot->graph()->setPen(QPen(color.lighter(200)));customPlot->graph()->setBrush(QBrush(color));// generate random walk data:QVector<QCPGraphData> timeData(250);for (int i=0; i<250; ++i){timeData[i].key = now + 24*3600*i;if (i == 0)timeData[i].value = (i/50.0+1)*(rand()/(double)RAND_MAX-0.5);elsetimeData[i].value = qFabs(timeData[i-1].value)*(1+0.02/4.0*(4-gi)) + (i/50.0+1)*(rand()/(double)RAND_MAX-0.5);}customPlot->graph()->data()->set(timeData);}// 时间刻度类QCPAxisTickerDateTime ; configure bottom axis to show date instead of number:QSharedPointer<QCPAxisTickerDateTime> dateTicker(new QCPAxisTickerDateTime);
//  时间开个格式dateTicker->setDateTimeFormat("d. MMMM\nyyyy");
//  给X轴设置时间刻度customPlot->xAxis->setTicker(dateTicker);// configure left axis text labels:QSharedPointer<QCPAxisTickerText> textTicker(new QCPAxisTickerText);textTicker->addTick(10, "a bit\nlow");textTicker->addTick(50, "quite\nhigh");customPlot->yAxis->setTicker(textTicker);// 设置刻度的字体 set a more compact font size for bottom and left axis tick labels:customPlot->xAxis->setTickLabelFont(QFont(QFont().family(), 8));customPlot->yAxis->setTickLabelFont(QFont(QFont().family(), 8));// set axis labels:customPlot->xAxis->setLabel("Date");customPlot->yAxis->setLabel("Random wobbly lines value");// make top and right axes visible but without ticks and labels:customPlot->xAxis2->setVisible(true);customPlot->yAxis2->setVisible(true);customPlot->xAxis2->setTicks(false);customPlot->yAxis2->setTicks(false);customPlot->xAxis2->setTickLabels(false);customPlot->yAxis2->setTickLabels(false);// set axis ranges to show all data:customPlot->xAxis->setRange(now, now+24*3600*249);customPlot->yAxis->setRange(0, 60);// 显示图例 show legend with slightly transparent background brush:customPlot->legend->setVisible(true);customPlot->legend->setBrush(QColor(255, 255, 255, 150));}

使用图片作为填充物,也就二十设置画刷

void MainWindow::setupTextureBrushDemo(QCustomPlot *customPlot)
{demoName = "Texture Brush Demo";// add two graphs with a textured fill:customPlot->addGraph();QPen redDotPen;redDotPen.setStyle(Qt::DotLine);redDotPen.setColor(QColor(170, 100, 100, 180));redDotPen.setWidthF(2);customPlot->graph(0)->setPen(redDotPen);
//  核心:设置画刷就是一个图片,实现图片作为2条线的填充customPlot->graph(0)->setBrush(QBrush(QPixmap("./balboa.jpg"))); // fill with texture of specified imagecustomPlot->addGraph();customPlot->graph(1)->setPen(QPen(Qt::red));// activate channel fill for graph 0 towards graph 1:customPlot->graph(0)->setChannelFillGraph(customPlot->graph(1));// generate data:QVector<double> x(250);QVector<double> y0(250), y1(250);for (int i=0; i<250; ++i){// just playing with numbers, not much to learn herex[i] = 3*i/250.0;y0[i] = 1+qExp(-x[i]*x[i]*0.8)*(x[i]*x[i]+x[i]);y1[i] = 1-qExp(-x[i]*x[i]*0.4)*(x[i]*x[i])*0.1;}// pass data points to graphs:customPlot->graph(0)->setData(x, y0);customPlot->graph(1)->setData(x, y1);// activate top and right axes, which are invisible by default:customPlot->xAxis2->setVisible(true);customPlot->yAxis2->setVisible(true);// make tick labels invisible on top and right axis:customPlot->xAxis2->setTickLabels(false);customPlot->yAxis2->setTickLabels(false);// set ranges:customPlot->xAxis->setRange(0, 2.5);customPlot->yAxis->setRange(0.9, 1.6);// assign top/right axes same properties as bottom/left:customPlot->axisRect()->setupFullAxesBox();
}

显示4个轴,添加标题 ,使用π坐标轴

  1. π坐标轴:QCPAxisTickerPi
  2. 图表题:QCPTextElement

void MainWindow::setupMultiAxisDemo(QCustomPlot *customPlot)
{customPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom);demoName = "Multi Axis Demo";customPlot->setLocale(QLocale(QLocale::English, QLocale::UnitedKingdom)); // period as decimal separator and comma as thousand separator
//  显示图例customPlot->legend->setVisible(true);QFont legendFont = font();  // start out with MainWindow's font..legendFont.setPointSize(9); // and make a bit smaller for legendcustomPlot->legend->setFont(legendFont);customPlot->legend->setBrush(QBrush(QColor(255,255,255,230)));// by default, the legend is in the inset layout of the main axis rect. So this is how we access it to change legend placement:customPlot->axisRect()->insetLayout()->setInsetAlignment(0, Qt::AlignBottom|Qt::AlignRight);// setup for graph 0: key axis left, value axis bottom// will contain left maxwell-like functioncustomPlot->addGraph(customPlot->yAxis, customPlot->xAxis);customPlot->graph(0)->setPen(QPen(QColor(255, 100, 0)));customPlot->graph(0)->setBrush(QBrush(QPixmap("./balboa.jpg"))); // fill with texture of specified imagecustomPlot->graph(0)->setLineStyle(QCPGraph::lsLine);customPlot->graph(0)->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssDisc, 5));customPlot->graph(0)->setName("Left maxwell function");// setup for graph 1: key axis bottom, value axis left (those are the default axes)// will contain bottom maxwell-like function with error barscustomPlot->addGraph();customPlot->graph(1)->setPen(QPen(Qt::red));customPlot->graph(1)->setBrush(QBrush(QPixmap("./balboa.jpg"))); // same fill as we used for graph 0customPlot->graph(1)->setLineStyle(QCPGraph::lsStepCenter);customPlot->graph(1)->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssCircle, Qt::red, Qt::white, 7));customPlot->graph(1)->setName("Bottom maxwell function");QCPErrorBars *errorBars = new QCPErrorBars(customPlot->xAxis, customPlot->yAxis);errorBars->removeFromLegend();errorBars->setDataPlottable(customPlot->graph(1));// setup for graph 2: key axis top, value axis right// will contain high frequency sine with low frequency beating:customPlot->addGraph(customPlot->xAxis2, customPlot->yAxis2);customPlot->graph(2)->setPen(QPen(Qt::blue));customPlot->graph(2)->setName("High frequency sine");// setup for graph 3: same axes as graph 2// will contain low frequency beating envelope of graph 2customPlot->addGraph(customPlot->xAxis2, customPlot->yAxis2);QPen blueDotPen;blueDotPen.setColor(QColor(30, 40, 255, 150));blueDotPen.setStyle(Qt::DotLine);blueDotPen.setWidthF(4);customPlot->graph(3)->setPen(blueDotPen);customPlot->graph(3)->setName("Sine envelope");// setup for graph 4: key axis right, value axis top// will contain parabolically distributed data points with some random perturbancecustomPlot->addGraph(customPlot->yAxis2, customPlot->xAxis2);customPlot->graph(4)->setPen(QColor(50, 50, 50, 255));customPlot->graph(4)->setLineStyle(QCPGraph::lsNone);customPlot->graph(4)->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssCircle, 4));customPlot->graph(4)->setName("Some random data around\na quadratic function");// generate data, just playing with numbers, not much to learn here:QVector<double> x0(25), y0(25);QVector<double> x1(15), y1(15), y1err(15);QVector<double> x2(250), y2(250);QVector<double> x3(250), y3(250);QVector<double> x4(250), y4(250);for (int i=0; i<25; ++i) // data for graph 0{x0[i] = 3*i/25.0;y0[i] = qExp(-x0[i]*x0[i]*0.8)*(x0[i]*x0[i]+x0[i]);}for (int i=0; i<15; ++i) // data for graph 1{x1[i] = 3*i/15.0;;y1[i] = qExp(-x1[i]*x1[i])*(x1[i]*x1[i])*2.6;y1err[i] = y1[i]*0.25;}for (int i=0; i<250; ++i) // data for graphs 2, 3 and 4{x2[i] = i/250.0*3*M_PI;x3[i] = x2[i];x4[i] = i/250.0*100-50;y2[i] = qSin(x2[i]*12)*qCos(x2[i])*10;y3[i] = qCos(x3[i])*10;y4[i] = 0.01*x4[i]*x4[i] + 1.5*(rand()/(double)RAND_MAX-0.5) + 1.5*M_PI;}// pass data points to graphs:customPlot->graph(0)->setData(x0, y0);customPlot->graph(1)->setData(x1, y1);errorBars->setData(y1err);customPlot->graph(2)->setData(x2, y2);customPlot->graph(3)->setData(x3, y3);customPlot->graph(4)->setData(x4, y4);// activate top and right axes, which are invisible by default:
//  显示顶部X轴,显示右侧Y轴customPlot->xAxis2->setVisible(true);customPlot->yAxis2->setVisible(true);// set ranges appropriate to show data:
//  设置每个轴的显示范围customPlot->xAxis->setRange(0, 2.7);customPlot->yAxis->setRange(0, 2.6);customPlot->xAxis2->setRange(0, 3.0*M_PI);customPlot->yAxis2->setRange(-70, 35);// set pi ticks on top axis:
//  设置顶部X轴为一个π轴customPlot->xAxis2->setTicker(QSharedPointer<QCPAxisTickerPi>(new QCPAxisTickerPi));// 给Plot 设置一个标题 使用QCPTextElement  add title layout element:customPlot->plotLayout()->insertRow(0);customPlot->plotLayout()->addElement(0, 0, new QCPTextElement(customPlot, "Way too many graphs in one plot", QFont("sans", 12, QFont::Bold)));// set labels:
//  设置每个轴的标签customPlot->xAxis->setLabel("Bottom axis with outward ticks");customPlot->yAxis->setLabel("Left axis label");customPlot->xAxis2->setLabel("Top axis label");customPlot->yAxis2->setLabel("Right axis label");// make ticks on bottom axis go outward:customPlot->xAxis->setTickLength(0, 5);customPlot->xAxis->setSubTickLength(0, 3);// make ticks on right axis go inward and outward:customPlot->yAxis2->setTickLength(3, 3);customPlot->yAxis2->setSubTickLength(1, 1);
}

QCostomPlot 示例注解 1相关推荐

  1. QCostomPlot 示例注解 2

    内部折现图的按照指数级的缩放 核心代码 customPlot->yAxis->setScaleType(QCPAxis::stLogarithmic); void MainWindow:: ...

  2. QCostomPlot 示例注解 3

    Item 在QCustomPlot中,所有的Item都继承自QCPAbstractItem,QCustomPlot给我们提供了一些Item item 说明 QCPItemBracket 括号Item ...

  3. 【Android APT】注解处理器 ( Element 注解节点相关操作 )

    文章目录 一.获取被 注解 标注的节点 二.Element 注解节点类型 三.VariableElement 注解节点相关操作 四.注解处理器 完整代码示例 五.博客资源 Android APT 学习 ...

  4. 【Java 注解】自定义注解 ( 注解属性定义与赋值 )

    文章目录 一.自定义注解格式 二.注解本质分析 三.注解属性及类型 四.注解属性类型 五.注解属性赋值简化操作 一.自定义注解格式 分析 Java 中自带的 @Override 注解 , 源码如下 : ...

  5. Mycat1.6之注解多租户

    2019独角兽企业重金招聘Python工程师标准>>> Mycat1.6之注解&多租户 博客分类: sql 永久链接: http://gaojingsong.iteye.co ...

  6. Spring注解编程基石(四)

    目录 AnnotationsScanner 扫描方法 扫描source为Class方法 扫描source为Method方法 辅助方法 MergedAnnotationSelector MergedAn ...

  7. swagger 修改dto注解_Swagger介绍及使用

    Swagger介绍及使用 导语: 相信无论是前端还是后端开发,都或多或少地被接口文档折磨过.前端经常抱怨后端给的接口文档与实际情况不一致.后端又觉得编写及维护接口文档会耗费不少精力,经常来不及更新.其 ...

  8. Mycat高级进阶---Mycat注解

    注解原理 概念:  MyCat对自身不支持的Sql语句提供了一种解决方案--在要执行的SQL语句前添加额外的一段由注解SQL组织的代码,这样Sql就能正确执行,这段代码称之为"注解" ...

  9. 防重复提交(注解+AOP)

    恶意请求,服务有瓶颈.复杂业务等! 让某个接口某个人(ip)在某段时间内只能请求N次. 在项目中比较常见的问题也有,那就是连点按钮导致请求多次. 全部由后端来控制,大致方案有使用拦截器.过滤器.切面. ...

最新文章

  1. TensorFlow2.0 系列开篇: Windows下GPU版本详细安装教程
  2. html5新特性:利用history的pushState等方法来解决使用ajax导致页面后退和前进的问题
  3. Java 抽象方法和抽象类基础知识
  4. 完全备份、差异备份、增量备份的区别
  5. 解决 ASP.NET Core 部署到 IIS,更新项目时文件夹正在使用错误
  6. vue.js语法和常用指令
  7. VB.Command()的参数
  8. 如何“ grep”连续流?
  9. 手机android wifi的密码查看,手机怎么查看wif无线i密码?安卓手机忘记无线i密码查看方法...
  10. crt计算机显示器,crt显示器最高分辨率_crt显示器最高刷新率
  11. vnc下:无法执行默认的终端模拟器
  12. 虚拟机和linux有啥关系,linux有什么虚拟机
  13. 生鲜在B2C电商模式下存在问题,O2O模式解决生鲜电商物流配送难题
  14. 音调识别 php,PHP 汉字转拼音工具
  15. vue : 无法加载文件 C:\Users\Administrator\AppData\Roaming\npm\vue.ps1,因为在此系统上禁止运行脚本
  16. iOS-开发者相关的几种证书
  17. WIN7环境下debug的使用
  18. LeetCode题解-222-Count Complete Tree Nodes
  19. C#中Abstract和Virtual(转载)
  20. 炼数成金邀请码:YY96

热门文章

  1. 老化试验机ami怎么寻找过去的数据_广东元耀:您知道塑料臭氧老化试验机检测浓度的方法有哪些吗?...
  2. 不重启修改计算机名称,批处理不重启快速修改计算机名
  3. MDP动态规划解法(三)
  4. Spring Cloud Sleuth + Zipkin + RabbitMQ +MySQL(三)
  5. Java 算法 新生舞会
  6. python列表转dict
  7. linux查看网卡物理编号_Centos 网卡命名规范及信息查看(物理网卡,虚拟网卡)...
  8. java的vector是什么类_java中vector类
  9. 一加7pro保存的录音文件在哪一个文件夹?
  10. 用canvas给自己的博客园加背景(二)