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

9.7.2 2-axes sample

../png/2_axis

C++ code

mglData y1(50), y2(50);
y1.Modify("0.3*sin(2*pi*x)"); y2.Modify("0.5+0.3*cos(2*pi*x)");
gr->Axis(mglPoint(-1,-1,-1),mglPoint(1,1,1),mglPoint(-1,-1,-1));
gr->Axis(); gr->Label('y',"axis 1",0);
gr->Plot(y1,"b");
gr->Axis(mglPoint(0,0,0),mglPoint(1,1,1),mglPoint(1,1,1));
gr->Axis(); gr->Label('y',"axis 2",0);
gr->Stem(y2,"r");

MGL code

new y1 50
new y2 50
modify y1 '0.3*sin(2*pi*x)'
modify y2 '0.5+0.3*cos(2*pi*x)'
axis -1 -1 -1 1 1 1
origin -1 -1 -1
axis
ylabel 'axis 1' 0
plot y1 'b'
axis 0 0 0 1 1 1
origin 1 1 1
axis
ylabel 'axis 2' 0
stem y2 'r'

Pure C code

HMDT y1 = mgl_create_data_size(50,1,1);
HMDT y2 = mgl_create_data_size(50,1,1);
mgl_data_modify(y1,"0.3*sin(2*pi*x)",0);
mgl_data_modify(y2,"0.5+0.3*cos(2*pi*x)",0);
mgl_set_axis_2d(gr,-1.,1.,-1.,1.);
mgl_set_origin(gr,-1.,-1.,-1.);
mgl_axis(gr,"xyz");
mgl_label_ext(gr,'y',"axis 1",0,-1.4,0.);
mgl_plot(gr,y1,"b");
mgl_set_axis_2d(gr,0.,0.,1.,1.);
mgl_set_origin(gr,1.,1.,1.);
mgl_axis(gr,"xyz");
mgl_label_ext(gr,'y',"axis 2",0,-1.4,0.);
mgl_stem(gr,y2,"r");

Fortran code

integer y1,y2, mgl_create_data_size
y1 = mgl_create_data_size(50,1,1)
y2 = mgl_create_data_size(50,1,1)
call mgl_data_modify(y1,'0.3*sin(2*pi*x)',0)
call mgl_data_modify(y2,'0.5+0.3*cos(2*pi*x)',0)
call mgl_set_axis_2d(gr,-1.,1.,-1.,1.)
call mgl_set_origin(gr,-1.,-1.,-1.)
call mgl_axis(gr,'xyz')
call mgl_label_ext(gr,'y','axis 1',0,-1.4,0.)
call mgl_plot(gr,y1,'b')
call mgl_set_axis_2d(gr,0.,0.,1.,1.)
call mgl_set_origin(gr,1.,1.,1.)
call mgl_axis(gr,'xyz')
call mgl_label_ext(gr,'y','axis 2',0,-1.4,0.)
call mgl_stem(gr,y2,'r')

Python

y1, y2 = mglData(50), mglData(50);
y1.Modify("0.3*sin(2*pi*x)");   y2.Modify("0.5+0.3*cos(2*pi*x)");
gr.SetRanges(-1,1,-1,1);   gr.SetOrigin(-1,-1);
gr.Axis();      gr.Label("y","axis 1",0);
gr.Plot(y1,"b");
gr.SetRanges(0,1,0,1);      gr.SetOrigin(1,1);
gr.Axis();      gr.Label("y","axis 2",0);
gr.Stem(y2,"r");

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