QCustomPlot Discussion and Comments

axis labels possible issue with multiple QCPCurve sReturn to overview

Hi
I am trying to plot multiple datasets on a single plot. The code below does plot the data correctly, i.e. multiple curves with a single set of axis. However, when I set the axis labels as in the code section:
plot->xAxis->setLabel(plotdatasets[0].X1label);
plot->xAxis->setVisible(true);

plot->yAxis->setLabel(plotdatasets[0].Y1label);
plot->yAxis->setVisible(true);

I get a label printed on each axis for EVERY QCPCurve drawn. I just want a single label for each of the x and y axis. Is there any way to get this to work?
Thanks in advance


// plotting
void PlotActions::plotxy(const QVector<PlotData> &plotdatasets) const
{
    // X1 and Y1 data
    //QCPCurve * singlecurveX1Y1=nullptr;     // empty vector of curves pointer. the curve must be plotted parametrically because, in general it's mulivalued i.e. it has looping
    QCPCurve * singlecurveX1Y2=nullptr;     // empty vector of curves pointer
    QVector<QCPCurve *> curves;
    QVector<QCPCurveData> curvedata;



    for(int i=0;i<plotdatasets.size();i++)          // plot all datasets on this chart
    {

         // plot the X1 and Y1 axes set*********
        // sanity and bug check:
        int X1size=plotdatasets[i].X1.size();
        int Y1size=plotdatasets[i].Y1.size();
        int Y2size=plotdatasets[i].Y2.size();
        int indxsize=plotdatasets[i].indx.size();
        if(X1size!=Y1size || (Y2size>0 && X1size!=Y2size) || X1size!=indxsize)     // check for internal bugs
        {
            qDebug()<<"Internal ERROR! near line 42 of plotactions.cpp: unequal sizes in plot data structure";
            exit(10);
        }
        curvedata.clear();

        if(plotdatasets[i].X1.size()>0 && plotdatasets[i].Y1.size()>0)     // X1, Y1 axis plot
        {
            curves.push_back(new QCPCurve(plot->xAxis, plot->yAxis));        // X1, Y1 curve data structure

            for(int idat=0;idat<indxsize;idat++)
            {
                curvedata.push_back(QCPCurveData(idat,plotdatasets[i].X1.at(idat),plotdatasets[i].Y1.at(idat)));
            }
            curves.at(curves.size()-1)->data()->set(curvedata,true);
            curves.at(curves.size()-1)->setPen(QPen(Qt::red));
        }
       // done plotting X1 and Y1 axes set for this curve ****************


 
       //************************
    }
    plot->xAxis->setLabel(plotdatasets[0].X1label);
    plot->xAxis->setVisible(true);

    plot->yAxis->setLabel(plotdatasets[0].Y1label);
    plot->yAxis->setVisible(true);


//    if(plotdatasets[0].Y2.size()>0)
//    {
//        plot->yAxis2->setLabel(plotdatasets[0].Y2label);
//        plot->yAxis2->setVisible(true);
//    }
//    else plot->yAxis2->setVisible(false);
//    plot->rescaleAxes();
//    plot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom | QCP::iSelectPlottables);
}

Please ignore my last post.
Please forgive me. My data were bad and this explains my problem.
Thanks