manpagez: man pages & more
info mathgl_en
Home | html | info | man
[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

2.5.14 Error sample

Error draw error boxes around the points. You can draw default boxes or semi-transparent symbol (like marker, see Line styles). Also you can set individual color for each box. The sample code is:

int sample(mglGraph *gr)
{
  mglData y;  mgls_prepare1d(&y);
  mglData x0(10), y0(10), ex0(10), ey0(10);
  float x;
  for(int i=0;i<10;i++)
  {
    x = i/9.;
    x0.a[i] = 2*x-1 + 0.1*mgl_rnd()-0.05;
    y0.a[i] = 0.7*sin(2*M_PI*x)+0.5*cos(3*M_PI*x)+0.2*sin(M_PI*x)+0.2*mgl_rnd()-0.1;
    ey0.a[i]=0.2; ex0.a[i]=0.1;
  }

  gr->SubPlot(2,2,0,"");  gr->Title("Error plot (default)");
  gr->Box();  gr->Plot(y.SubData(-1,0));  gr->Error(x0,y0,ex0,ey0,"ko");

  gr->SubPlot(2,2,1,"");  gr->Title("'!' style; no e_x");
  gr->Box();  gr->Plot(y.SubData(-1,0));  gr->Error(x0,y0,ey0,"o!rgb");

  gr->SubPlot(2,2,2,"");  gr->Title("'\\@' style");
  gr->Box();  gr->Plot(y.SubData(-1,0));  gr->Error(x0,y0,ex0,ey0,"@","alpha 0.5");

  gr->SubPlot(2,2,3); gr->Title("3d variant");  gr->Rotate(50,60);
  for(int i=0;i<10;i++)
    gr->Error(mglPoint(2*mgl_rnd()-1,2*mgl_rnd()-1,2*mgl_rnd()-1),
              mglPoint(0.2,0.2,0.2),"bo");
  gr->Axis();
  return 0;
}
Example of Error()

This document was generated on April 13, 2012 using texi2html 5.0.

© manpagez.com 2000-2025
Individual documents may contain additional copyright information.