本文整理汇总了C++中QwtPlotCurve::data方法的典型用法代码示例。如果您正苦于以下问题:C++ QwtPlotCurve::data方法的具体用法?C++ QwtPlotCurve::data怎么用?C++ QwtPlotCurve::data使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QwtPlotCurve
的用法示例。
在下文中一共展示了QwtPlotCurve::data方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AddPlotData
void PlotWidget::AddPlotData(QString title, float plotData)
{
if(!_curves.contains(title))
{
//QwtPointSeriesData *points = CreatePointSeriesFromArray(&plotData, 1);
QwtPlotCurve *curve = new QwtPlotCurve(title);
curve->setPen(QColor(255,0,0), 2.0);
if(_showMarkers)
{
/*QwtSymbol *symbol1 = new QwtSymbol();
symbol1->setStyle(QwtSymbol::Ellipse);
symbol1->setPen(QColor(Qt::black));
symbol1->setSize(4);*/
curve->setSymbol(GetDefaultMarker());
}
QVector<QPointF> nData;
QPointF p(0, plotData);
nData.append(p);
curve->setSamples(nData);
curve->attach(_plot);
_curves.insert(title, curve);
}
else
{
QwtPlotCurve *curve =_curves.value(title);
QwtSeriesData<QPointF>* data = curve->data();
int s = data->size();
QPointF p(s, plotData);
//QVector<QPointF> nData(s+1);
QVector<QPointF> nData;
for(int i = 0; i < s; i++)
{
QPointF p(data->sample(i).x(), data->sample(i).y());
nData.append(p);
}
nData.append(p);
curve->setSamples(nData);
}
CheckNReplot();
}
示例2: build_stats
//TL modified
void Scatterplot_gui::build_stats()
{
QString val;
_stats.clear();
QwtPlotCurve* curve = curve_id_ ;
if( curve )
val.setNum( curve->data().size() );
else
val.setNum( 0 );
_stats.push_back(Pair("plotted data: ",qstring2string(val)));
val.setNum(plotter_->correlation());
_stats.push_back(Pair("Correlation: ",qstring2string(val)));
_stats.push_back(Pair("Variable X",""));
val.setNum(plotter_->mean(Scatter_plot::Xvar));
_stats.push_back(Pair("Mean: ",qstring2string(val)));
val.setNum(plotter_->var(Scatter_plot::Xvar));
_stats.push_back(Pair("Variance: ",qstring2string(val)));
_stats.push_back(Pair("Variable Y",""));
val.setNum(plotter_->mean(Scatter_plot::Yvar));
_stats.push_back(Pair("Mean: ",qstring2string(val)));
val.setNum(plotter_->var(Scatter_plot::Yvar));
_stats.push_back(Pair("Variance: ",qstring2string(val)));
if( control_panel_->ls_fit_shown() ) {
_stats.push_back(Pair("Linear Regression Line",""));
std::pair<float,float> lsfit = plotter_->least_sq_fit();
val.setNum( lsfit.first );
_stats.push_back(Pair("Slope: ",qstring2string(val)));
val.setNum( lsfit.second );
_stats.push_back(Pair("Intercept: ",qstring2string(val)));
}
}
示例3: refresh_stats
void Scatterplot_gui::refresh_stats() {
QwtPlotCurve* curve = curve_id_ ;
int data_size = 0;
if( curve )
data_size = curve->data().size();
update_stats_value( 0, data_size ); //plotted data
update_stats_value( 2, plotter_->correlation() ); //var X data count
update_stats_value( 12, plotter_->data_count( Scatter_plot::Xvar ) ); //var X data count
update_stats_value( 13, plotter_->mean( Scatter_plot::Xvar ) ); // var X mean
update_stats_value( 14, plotter_->var( Scatter_plot::Xvar ) ); // var X variance
update_stats_value( 22, plotter_->data_count( Scatter_plot::Yvar ) ); // var Y data count
update_stats_value( 23, plotter_->mean( Scatter_plot::Yvar ) ); // var Y mean
update_stats_value( 24, plotter_->var( Scatter_plot::Yvar ) ); // var Y variance
std::pair<float,float> lsfit = plotter_->least_sq_fit();
control_panel_->show_lsfit_coeffs( lsfit.first, lsfit.second );
}
示例4: on_buttonBox_accepted
void DialogSavePlot::on_buttonBox_accepted()
{
QString selectedDir = QFileDialog::getExistingDirectory(this);
if (selectedDir.isNull() || selectedDir.isEmpty()) return;
QwtPlotItemList list = plot->itemList();
QFile plotFile(selectedDir + QDir::separator() + "plot.p");
plotFile.open(QIODevice::WriteOnly);
QTextStream plotStream(&plotFile);
plotStream << "set terminal postscript enhanced color\nset output '| ps2pdf - plot.pdf'\n";
if (!ui->cbxShowLegend->isChecked())
{
plotStream << "set nokey\n";
}
QString horizontalAxis = ui->leHorizontalAxis->text();
if (!horizontalAxis.isNull() && !horizontalAxis.isEmpty())
{
plotStream << "set xlabel \"" + horizontalAxis + "\"\n";
}
QString verticalAxis = ui->leVerticakAxis->text();
if (!verticalAxis.isNull() && !verticalAxis.isEmpty())
{
plotStream << "set ylabel \"" + verticalAxis + "\"\n";
}
QString color;
if (ui->cbxSameColor->isChecked())
{
color = " lt 1";
}
plotStream << "plot ";
bool first = true;
foreach(const QwtPlotItem *item, list)
{
const QString &name = item->title().text();
if (name.compare("index") == 0) continue;
QwtPlotCurve *curve = (QwtPlotCurve*)(item);
if (curve == 0) continue;
QFile f(selectedDir + QDir::separator() + name);
f.open(QIODevice::WriteOnly);
QTextStream out(&f);
int n = curve->dataSize();
for (int i = 0; i < n; i++)
{
const QPointF &p = curve->data()->sample(i);
out << p.x() << ' ' << p.y() << '\n';
}
out.flush();
f.close();
if (first)
{
first = false;
}
else
{
plotStream << ", ";
}
plotStream << '\"' + name + '\"' + " w l" + color;
}
plotStream << '\n';
plotStream.flush();
plotFile.close();
}
示例5: paint_stats
void Scatterplot_gui::paint_stats( QPainter& painter ) {
QString val;
const int hspace = 90;
QwtPlotCurve* curve = curve_id_ ;
if( curve )
val.setNum( curve->data().size() );
else
val.setNum( 0 );
painter.drawText( 0,0, "plotted data: " );
painter.drawText( hspace,0, val );
painter.translate( 0, 25 );
val.setNum( plotter_->correlation() );
painter.drawText( 0,0, "Correlation: " );
painter.drawText( hspace,0, val );
painter.translate( 0, 25 );
painter.drawText( 0,0, "Variable X" );
painter.translate( 0, 20 );
val.setNum( plotter_->mean( Scatter_plot::Xvar ) );
painter.drawText( 0,0, "Mean: " );
painter.drawText( hspace,0, val );
painter.translate( 0, 15 );
val.setNum( plotter_->var( Scatter_plot::Xvar ) );
painter.drawText( 0,0, "Variance: " );
painter.drawText( hspace,0, val );
painter.translate( 0, 25 );
painter.drawText( 0,0, "Variable Y" );
painter.translate( 0, 20 );
val.setNum( plotter_->mean( Scatter_plot::Yvar ) );
painter.drawText( 0,0, "Mean: " );
painter.drawText( hspace,0, val );
painter.translate( 0, 15 );
val.setNum( plotter_->var( Scatter_plot::Yvar ) );
painter.drawText( 0,0, "Variance: " );
painter.drawText( hspace,0, val );
painter.translate( 0, 25 );
if( control_panel_->ls_fit_shown() ) {
painter.drawText( 0,0, "Linear Regression Line" );
painter.translate( 0, 20 );
std::pair<float,float> lsfit = plotter_->least_sq_fit();
val.setNum( lsfit.first );
painter.drawText( 0,0, "Slope: " );
painter.drawText( hspace,0, val );
painter.translate( 0, 15 );
val.setNum( lsfit.second );
painter.drawText( 0,0, "Intercept: " );
painter.drawText( hspace,0, val );
painter.translate( 0, 25 );
}
}