Exemple #1
0
void QPplot_gui::set_analysis_type( const QString& type ) {
  if( type == "QQ-plot" ) 
    qpploter_->analysis_type( QPplot::QQplot );
  if( type == "PP-plot" ) 
    qpploter_->analysis_type( QPplot::PPplot );

  int size;
  std::pair<double*,double*> curve = qpploter_->plotting_data(size);
  refresh_plot(  curve, size);
}
Exemple #2
0
void QPplot_gui::update_all() {
  int size;
  std::pair<double*,double*> curve = qpploter_->plotting_data(size);
  refresh_plot(  curve, size);
  refresh_stats();  
}
Exemple #3
0
void Histogram_gui::changeCurve(const QString & s)
{
	std::map<float,int>::iterator itr;

	int total = histogram_->rawDataSize();
	int i = 0;
	QwtText tfp("Probability");
	tfp.setFont(plot_->axisFont(QwtPlot::yLeft));	

	QwtText tff("Frequency");
	tff.setFont(plot_->axisFont(QwtPlot::yLeft));	

	QColor blueColor(Qt::blue);
	const QPen pen(blueColor);
	std::pair<double*,double*> curve = histogram_->plotting_data();
	if (!curve.first) {
		appli_message("No data present");
		return;
	}

	if (s == "cdf") {
	    std::map<float, int> freqCount = histogram_->frequency();

		_cdfCurve->setAxis(QwtPlot::xBottom, QwtPlot::yLeft);


		plot_->setAxisTitle(QwtPlot::yLeft, tfp);
		plot_->enableAxis(QwtPlot::yRight,false);

		curve_grid_->enableY(true);
		curve_grid_->setYAxis(QwtPlot::yLeft);
		
		plot_->enableAxis(QwtPlot::yLeft);

		curve_id_->setStyle(QwtPlotCurve::NoCurve);
		_cdfCurve->setStyle(QwtPlotCurve::Lines);

		double * x = new double[freqCount.size()+1];
		double * y = new double[freqCount.size()+1];

		y[0] = 0;
		for (itr = freqCount.begin(); itr != freqCount.end(); ++itr,++i) {
			x[i+1] = itr->first;
			y[i+1] = y[i]+(double)(itr->second)/(double)(total);
		}
		x[0] = x[1];

		_cdfCurve->setPen(pen);
		_cdfCurve->setData(  x, y, freqCount.size()+1 );
		refresh_plot( _cdfCurve, std::make_pair( x,y ), freqCount.size()+1 );
		refresh_stats();


		delete []x;
		delete []y;
	}
	else if (s == "pdf") {
	        //_cdfCurve->detach();
		
		plot_->enableAxis(QwtPlot::yRight, false);
		plot_->setAxisTitle(QwtPlot::yLeft, tff);
		plot_->enableAxis(QwtPlot::xBottom);
		
		curve_id_->setAxis(QwtPlot::xBottom, QwtPlot::yLeft);
		curve_grid_->setYAxis(QwtPlot::yLeft);
		curve_grid_->enableY(true);

		curve_grid_->setXAxis(QwtPlot::xBottom);
		curve_grid_->enableX(true);

		_cdfCurve->setStyle(QwtPlotCurve::NoCurve);
		curve_id_->setStyle(QwtPlotCurve::Histogram);

		int size = histogram_->bins()+1;
		double* x = new double[size+1];
		double* y = new double[size+1];
		for( int i =0 ; i < size ; i++ ) {
			x[i+1] = curve.first[i];
			y[i+1] = curve.second[i];
		}
		x[0] = x[1];
		y[0] = 0.0;

		refresh_plot(  std::make_pair( x,y ), size+1 );
		refresh_stats();
		delete []x;
		delete []y;
	}
	else {

	    std::map<float, int> freqCount = histogram_->frequency();

	    _cdfCurve->setAxis(QwtPlot::xBottom, QwtPlot::yRight);

	    plot_->enableAxis(QwtPlot::yRight, true);
	    plot_->enableAxis(QwtPlot::yLeft, true);
				   
	    curve_grid_->setYAxis(QwtPlot::yLeft);


	    plot_->setAxisTitle(QwtPlot::yLeft, tff);
	    plot_->setAxisTitle(QwtPlot::yRight, tfp);

	    _cdfCurve->setStyle(QwtPlotCurve::Lines);
	    curve_id_->setStyle(QwtPlotCurve::Histogram);

	    double * x = new double[freqCount.size()+1];
	    double * y = new double[freqCount.size()+1];

	    y[0] = 0;
	    for (itr = freqCount.begin(); itr != freqCount.end(); ++itr,++i) {
	      x[i+1] = itr->first;
	      y[i+1] = y[i]+(double)(itr->second)/(double)(total);
	    }
	    x[0] = x[1];

	    _cdfCurve->setPen(pen);
	    _cdfCurve->setData( x, y, freqCount.size()+1 );
	    refresh_plot( _cdfCurve, std::make_pair( x,y ), freqCount.size()+1 );
	    //refresh_stats();


	    int size = histogram_->bins()+1;
	    double* x1 = new double[size+1];
	    double* y1 = new double[size+1];
	    for( int i =0 ; i < size ; i++ ) {
	      x1[i+1] = curve.first[i];
	      y1[i+1] = curve.second[i];
	    }
	    x1[0] = x1[1];
	    y1[0] = 0.0;

	    refresh_plot(  std::make_pair( x1,y1 ), size+1 );
	    refresh_stats();

	    delete []x1;
	    delete []y1;
	    delete []x;
	    delete []y;

	}
		  //plot_->replot();

}