Hello. I have been working with QCustomPlot for a while now. There is one issue that I am always frustrated about with QCustomPlot - it is impossible/quite hard to change the color of a single point on the graph without altering a whole graph.

For example, I have setup a 3'rd graph on my plot:

    customPlot->addGraph(customPlot->xAxis, customPlot->yAxis);
    customPlot->graph(2)->setLineStyle((QCPGraph::LineStyle)QCPGraph::lsNone);
    customPlot->graph(2)->setScatterStyle(QCPScatterStyle::ssTriangle);
    //customPlot->graph()->setScatterStyle(QCPScatterStyle(QPixmap("../sun.jpg")));
    QPen pen_cursor;
    pen_cursor.setWidth(20);
    pen_cursor.setColor(QColor(244, 200, 0));
    customPlot->graph(2)->setPen(pen_cursor);
    

To create/and remove points on the graph, I have created a seperate class, see the methods implemented below:

Cursor::Cursor(QWidget *parent) : QMainWindow{parent} { cursor_count = 0; }

void Cursor::addPoint_cursor(double x, double y)
{
    qv_x_cursor.append(x);
    qv_y_cursor.append(y);
}

void Cursor::plot_cursor(QCustomPlot *customPlot)
{
    customPlot->graph(2)->setData(qv_x_cursor, qv_y_cursor);
    customPlot->replot();
    customPlot->update();
}

void Cursor::change_color(QCustomPlot *customPlot, QColor color)
{
    QPen pen;
    pen.setColor(color);
    customPlot->graph(2)->setPen(pen);
}

}

In my mainwindow.cpp I can do the following to plot the graph:

    cursor_local->change_color(customPlot,QColor(255,0,0));
    cursor_local->addPoint_cursor(1, 2);
    cursor_local->plot_cursor(customPlot);

    cursor_local->change_color(customPlot,QColor(0,255,0));
    cursor_local->addPoint_cursor(2, 4);
    cursor_local->plot_cursor(customPlot);

    cursor_local->change_color(customPlot,QColor(0,0,255));
    cursor_local->addPoint_cursor(3, 7);
    cursor_local->plot_cursor(customPlot);

As you can see from the code above, I am trying to plot 3 different points on the graph with different colors. However, what happens is that the whole graph is recolored to the last color which is totally not what I want.

See the image below of the result:
https://ibb.co/jz2WRdH


I would really appreciate if someone could help me understand how to adjust the color of individual points on the graph instead of changing color of the whole graph. I would really appreciate that. I have looked through another simillar post here:
https://www.qcustomplot.com/index.php/support/forum/122

But could not quite find solution but just pieces of code that I could not properly put together and get it to work. Also, there seems to be more people confused about this so perhaps it will help others as well. Thanks in advance.