[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
9.5.1 1D plot sample

C++ code
mglData y0(50); y0.Modify("sin(pi*(2*x-1))"); gr->SubPlot(2,2,0); gr->Plot(y0); gr->Box(); gr->SubPlot(2,2,1); mglData y1(50,2); y1.Modify("sin(pi*2*x-pi)"); y1.Modify("cos(pi*2*x-pi)/2",1); gr->Plot(y1); gr->Box(); mglData x(50); x.Modify("cos(pi*2*x-pi)"); gr->Plot(x,y0,"Y+"); gr->Plot(y1.SubData(-1,0),y1.SubData(-1,1),"q|"); gr->SubPlot(2,2,2); gr->Rotate(60,40); mglData z(50); z.Modify("2*x-1"); gr->Plot(x,y0,z); gr->Box(); mglData y2(10,3); y2.Modify("cos(pi*(2*x-1-y))"); y2.Modify("2*x-1",2); gr->Plot(y2.SubData(-1,0),y2.SubData(-1,1),y2.SubData(-1,2),"bo "); gr->SubPlot(2,2,3); gr->Rotate(60,40); gr->Bars(x,y0,z,"ri"); gr->Box();
MGL code
new y0 50: modify y0 'sin(pi*(2*x-1))' subplot 2 2 0 plot y0: box subplot 2 2 1 new y1 50 2 modify y1 'sin(pi*2*x-pi)' modify y1 'cos(pi*2*x-pi)/2' 1 plot y1: box new x 50: modify x 'cos(pi*2*x-pi)' plot x y0 'Y+' plot y1(:,0) y(:,1) 'q|' subplot 2 2 2:rotate 60 40 new z 50: modify z '2*x-1' plot x y0 z 'g':box new y2 10 3 modify y2 'cos(pi*(2*x-1-y))' modify y2 '2*x-1' 2 plot y2(:,0) y2(:,1) y2(:,2) 'bo ' subplot 2 2 3:rotate 60 40 bars x y0 z 'r':box