本文整理汇总了C++中QCustomPlot::clearPlottables方法的典型用法代码示例。如果您正苦于以下问题:C++ QCustomPlot::clearPlottables方法的具体用法?C++ QCustomPlot::clearPlottables怎么用?C++ QCustomPlot::clearPlottables使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QCustomPlot
的用法示例。
在下文中一共展示了QCustomPlot::clearPlottables方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: update
bool BarGraph::update(const GRT::VectorDouble &sample ) {
if( !initialized ) return false;
this->data = sample;
//If the plot is hidden then there is no point in updating the graph
if( this->isHidden() ) {
return true;
}
QCustomPlot *plot = ui->graph;
QVector<double> keyData;
QVector<double> valueData;
QVector<double> tickVector;
QVector<QString> tickLabels;
const unsigned int K = (unsigned int)data.size();
plot->clearPlottables();
QCPBars *bar = new QCPBars(plot->xAxis,plot->yAxis);
plot->addPlottable( bar );
//Add the data to the graph
for(unsigned int k=0; k<K; k++) {
keyData << k+1;
valueData << data[k];
}
bar->setData(keyData, valueData);
//Add the tick labels
for(unsigned int k=0; k<K; k++) {
tickVector << double(k+1);
tickLabels << QString::fromStdString( GRT::Util::intToString( k+1 ) );
}
plot->xAxis->setAutoTicks(false);
plot->xAxis->setAutoTickLabels(false);
plot->xAxis->setTickVector( tickVector );
plot->xAxis->setTickVectorLabels( tickLabels );
plot->xAxis->setLabel("Features");
plot->yAxis->setLabel("Values");
plot->rescaleAxes();
plot->replot();
return true;
}