Inherits QObject.
Groups multiple QCPBars together so they appear side by side.
When showing multiple QCPBars in one plot which have bars at identical keys, it may be desirable to have them appearing next to each other at each key. This is what adding the respective QCPBars plottables to a QCPBarsGroup achieves. (An alternative approach is to stack them on top of each other, see QCPBars::moveAbove.)
Usage
To add a QCPBars plottable to the group, create a new group and then add the respective bars intances:
Alternatively to appending to the group like shown above, you can also set the group on the QCPBars plottable via QCPBars::setBarsGroup.
The spacing between the bars can be configured via setSpacingType and setSpacing. The bars in this group appear in the plot in the order they were appended. To insert a bars plottable at a certain index position, or to reposition a bars plottable which is already in the group, use insert.
To remove specific bars from the group, use either remove or call QCPBars::setBarsGroup(0) on the respective bars plottable.
To clear the entire group, call clear, or simply delete the group.
Example
The image above is generated with the following code:
QVector<double> datax = QVector<double>() << 1 << 2 << 3 << 4;
QVector<double> datay1 = QVector<double>() << 0.6 << 0.5 << 0.3 << 0.15;
QVector<double> datay2 = QVector<double>() << 0.3 << 0.28 << 0.2 << 0.1;
QVector<double> datay3 = QVector<double>() << 0.33 << 0.31 << 0.27 << 0.13;
customPlot->addPlottable(bars);
bars->
setPen(QColor(0, 0, 255));
bars =
new QCPBars(customPlot->xAxis, customPlot->yAxis);
customPlot->addPlottable(bars);
bars->
setBrush(QColor(180, 00, 120, 50));
bars->
setPen(QColor(180, 00, 120));
bars =
new QCPBars(customPlot->xAxis, customPlot->yAxis);
customPlot->addPlottable(bars);
bars->
setBrush(QColor(255, 154, 0, 50));
bars->
setPen(QColor(255, 154, 0));
customPlot->xAxis->setRange(0.1, 4.9);
customPlot->yAxis->setRange(0, 0.7);
customPlot->xAxis->setAutoTickStep(false);
customPlot->xAxis->setTickStep(1);