Example #1
0
void PlPlotWidget::plotLinearFit(int size, std::vector<double> &xp,std::vector<double> &yp,std::vector<double> &yp_err, double m, double c){

    plot->clearWidget();
    //plot->setBackgroundColor(255,255,255,1);

    int   i;
    double max_x, max_y;

    std::vector<double>::iterator result_min_x, result_max_x;
    std::vector<double>::iterator result_min_y, result_max_y;

    PLFLT *x = new PLFLT[size];
    PLFLT *y = new PLFLT[size];
    PLFLT *y_fit = new PLFLT[size];
    PLFLT *y_err_hi = new PLFLT[size];
    PLFLT *y_err_lo = new PLFLT[size];

    for(i=0;i<size;i++){  // is there a better way with first value
        x[i]=xp[i];
        y[i]=yp[i];
        y_fit[i]=m*xp[i]+c;
        y_err_hi[i]=yp[i]+yp_err[i];
        y_err_lo[i]=yp[i]-yp_err[i];
    }

    result_min_x = std::min_element(xp.begin(), xp.end());
    result_max_x = std::max_element(xp.begin(), xp.end());
    result_min_y = std::min_element(yp.begin(), yp.end());
    result_max_y = std::max_element(yp.begin(), yp.end());

    max_x = (*result_max_x)*(1.2);	//sets the axis to be 20% larger than the max value
    max_y = (*result_max_y)*(1.2);

    plcol0( 14 );
    plenv( 0, max_x, 0, max_y, 0, 1 );
    plcol0( 1 );
    pllab( "time (s)", "\gl", "FRAP DATA" );

    plcol0( 14 );
    plwid( 2 );
    plpoin( size, x, y, 20);
    plerry( size, x, y_err_hi,y_err_lo);
    plwid( 1 );

    plcol0( 14 );
    plwid( 2 );
    plline( size, x, y_fit );
    plwid( 1 );

    delete[] x;
    delete[] y;
    delete[] y_fit;
    delete[] y_err_hi;
    delete[] y_err_lo;
}
Example #2
0
void plplot_plot_xy1y2(plot_driver_type * driver     , 
                       const char * label , 
                       double_vector_type * x  , 
                       double_vector_type * y1  , 
                       double_vector_type * y2  , 
                       line_attribute_type line_attr) {

  int size = double_vector_size( x );
  
  plplot_logtransform_x( driver , x );
  plplot_logtransform_x( driver , y1 );
  plplot_logtransform_x( driver , y2 );
  
  plplot_setup_linestyle( line_attr );
  plerry(size , double_vector_get_ptr(x) , double_vector_get_ptr(y1) , double_vector_get_ptr(y2));
}