[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9. Samples

This chapter contain a lot of sample codes for all types of plots and for most important examples and hints. The same sample (with pictures) you can find at http://mathgl.sf.net/pictures.html. Most of examples have the sample code on 5 languages: C++, MGL, C, Fortran and Python. However, I put only C++ code for some of examples due to a lot of them and clearency how to write code for other languages. All samples are divided on 6 large categories. The minimal code to view the samples for different languages are following. C++ code For compilation use: g++ -o sample sample.cpp -lmgl.

#include <mgl/mgl_zb.h>
int main()
{
    mglGraph *gr = new mglGraphZB;
    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    // put sample code here
    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    gr->ShowImage();    delete gr;
    return 0;
}

MGL code For preview use: mglview sample.mgl.

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# put sample code here
#   -->   you may use sample as is :)
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Pure C code For compilation use: gcc -o sample sample.c -lmgl.

#include <mgl/mgl_c.h>
int main()
{
    HMGL gr = mgl_create_graph_zb(600,400);
    /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
    /* put sample code here              */
    /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
    mgl_show_image(gr,"",0);
    mgl_delete_graph(gr);
    return 0;
}

Fortran code For compilation use: gfortran -o sample sample.f90 -lmgl. Note, fortran don’t have argument checking. So you have to take special attention to pass real variables to real arguments of functions and integer variables to integer arguments of functions. There is no other special checking for that!!!

integer gr, mgl_create_graph_zb
gr = mgl_create_graph_zb(600,400)
!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
! put sample code here
!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
call mgl_show_image(gr,'',0)
call mgl_delete_graph(gr)
end

Python For preview use: python sample.py.

from mathgl import *
gr = mglGraph();
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# put sample code here
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
gr.ShowImage();

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.1 1D plotting samples


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.1.1 Plot sample

png/plot

C++ code

mglData y(50,3);
y.Modify("0.7*sin(2*pi*x) + 0.5*cos(3*pi*x) + 0.2*sin(pi*x)",0);
y.Modify("sin(2*pi*x)",1);
y.Modify("cos(2*pi*x)",2);
gr->Box();
gr->Plot(y);

MGL code

new y 50 3
modify y '0.7*sin(2*pi*x) + 0.5*cos(3*pi*x) + 0.2*sin(pi*x)'
modify y 'sin(2*pi*x)' 1
modify y 'cos(2*pi*x)' 2
box
plot y

Pure C code

HMDT y = mgl_create_data_size(50,3,1);
mgl_data_modify(y,"0.7*sin(2*pi*x) + 0.5*cos(3*pi*x) + 0.2*sin(pi*x)",0);
mgl_data_modify(y,"sin(2*pi*x)",1);
mgl_data_modify(y,"cos(2*pi*x)",2);
mgl_box(gr,1);
mgl_plot(gr,y,NULL);
mgl_delete_data(y);

Fortran code

integer y, mgl_create_data_size
y = mgl_create_data_size(50,3,1)
call mgl_data_modify(y,'0.7*sin(2*pi*x) + 0.5*cos(3*pi*x) + 0.2*sin(pi*x)',0)
call mgl_data_modify(y,'sin(2*pi*x)',1)
call mgl_data_modify(y,'cos(2*pi*x)',2)
call mgl_box(gr,1)
call mgl_plot(gr,y,'')
call mgl_delete_data(y)

Python

y = mglData(50,3);
y.Modify("0.7*sin(2*pi*x)+0.5*cos(3*pi*x)+0.2*sin(pi*x)",0);
y.Modify("sin(2*pi*x)",1);
y.Modify("cos(2*pi*x)",2);
gr.Box();
gr.Plot(y);

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.1.2 Radar sample

png/radar

C++ code

mglData y(10,3);
y.Modify("0.4*sin(pi*(2*x+y/2))+0.1*rnd");
gr->Radar(y,"#");

MGL code

new y 10 3
modify y '0.4*sin(pi*(2*x+y/2))+0.1*rnd'
radar y '#'

Pure C code

HMDT y = mgl_create_data_size(10,3,1);
mgl_data_modify(y,"0.4*sin(pi*(2*x+y/2))+0.1*rnd",0);
mgl_radar(gr,y,"#",-1);
mgl_delete_data(y);

Fortran code

integer y, mgl_create_data_size
y = mgl_create_data_size(10,3,1)
call mgl_data_modify(y,'0.4*sin(pi*(2*x+y/2))+0.1*rnd',0)
call mgl_radar(gr,y,'#',-1.)
call mgl_delete_data(y)

Python

y = mglData(10,3);
y.Modify("0.4*sin(pi*(2*x+y/2))+0.1*rnd");
gr.Radar(y,"#");

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.1.3 Tens sample

png/tens

C++ code

mglData y(50), c(50);
y.Modify("0.7*sin(2*pi*x) + 0.5*cos(3*pi*x) + 0.2*sin(pi*x)");
c.Modify("sin(2*pi*x)");
gr->Box();
gr->Tens(y,c);

MGL code

new y 50
new c 50
modify y '0.7*sin(2*pi*x) + 0.5*cos(3*pi*x) + 0.2*sin(pi*x)'
modify c 'sin(2*pi*x)'
box
tens y c

Pure C code

HMDT y = mgl_create_data_size(50,1,1);
HMDT c = mgl_create_data_size(50,1,1);
mgl_data_modify(y,"0.7*sin(2*pi*x) + 0.5*cos(3*pi*x) + 0.2*sin(pi*x)",0);
mgl_data_modify(c,"sin(2*pi*x)",0);
mgl_box(gr,1);
mgl_tens(gr,y,c,NULL);
mgl_delete_data(y);
mgl_delete_data(c);

Fortran code

integer y, c, mgl_create_data_size
y = mgl_create_data_size(50,1,1)
c = mgl_create_data_size(50,1,1)
call mgl_data_modify(y,'0.7*sin(2*pi*x) + 0.5*cos(3*pi*x) + 0.2*sin(pi*x)',0)
call mgl_data_modify(c,'sin(2*pi*x)',0)
call mgl_box(gr,1)
call mgl_tens(gr,y,'')
call mgl_delete_data(y)
call mgl_delete_data(c)

Python

y = mglData(50);
c = mglData(50);
y.Modify("0.7*sin(2*pi*x)+0.5*cos(3*pi*x)+0.2*sin(pi*x)");
c.Modify("sin(2*pi*x)");
gr.Box();
gr.Tens(y,c);

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.1.4 Area sample

png/area

C++ code

mglData y(50,3);
y.Modify("0.7*sin(2*pi*x) + 0.5*cos(3*pi*x) + 0.2*sin(pi*x)",0);
y.Modify("sin(2*pi*x)",1);
y.Modify("cos(2*pi*x)",2);
gr->Org=mglPoint(0,0);
gr->Box();
gr->Area(y);

MGL code

new y 50 3
modify y '0.7*sin(2*pi*x) + 0.5*cos(3*pi*x) + 0.2*sin(pi*x)'
modify y 'sin(2*pi*x)' 1
modify y 'cos(2*pi*x)' 2
origin 0 0
box
area y

Pure C code

HMDT y = mgl_create_data_size(50,3,1);
mgl_data_modify(y,"0.7*sin(2*pi*x) + 0.5*cos(3*pi*x) + 0.2*sin(pi*x)",0);
mgl_data_modify(y,"sin(2*pi*x)",1);
mgl_data_modify(y,"cos(2*pi*x)",2);
mgl_set_origin(gr,0.,0.,0.);
mgl_box(gr,1);
mgl_area(gr,y,NULL);
mgl_delete_data(y);

Fortran code

integer y, mgl_create_data_size
y = mgl_create_data_size(50,3,1)
call mgl_data_modify(y,'0.7*sin(2*pi*x) + 0.5*cos(3*pi*x) + 0.2*sin(pi*x)',0)
call mgl_data_modify(y,'sin(2*pi*x)',1)
call mgl_data_modify(y,'cos(2*pi*x)',2)
call mgl_set_origin(gr,0.,0.,0.)
call mgl_box(gr,1)
call mgl_area(gr,y,'')
call mgl_delete_data(y)

Python

y = mglData(50,3);
y.Modify("0.7*sin(2*pi*x)+0.5*cos(3*pi*x)+0.2*sin(pi*x)",0);
y.Modify("sin(2*pi*x)",1);
y.Modify("cos(2*pi*x)",2);
gr.SetOrigin(0.,0.);
gr.Box();
gr.Area(y);

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.1.5 Area with gradient filling sample

png/area_2

C++ code

mglData y(50,3);
y.Modify("0.7*sin(2*pi*x) + 0.5*cos(3*pi*x) + 0.2*sin(pi*x)",0);
y.Modify("sin(2*pi*x)",1);
y.Modify("cos(2*pi*x)",2);
gr->Org=mglPoint(0,0);
gr->Box();
gr->Area(y,"cbgGyr");

MGL code

new y 50 3
modify y '0.7*sin(2*pi*x) + 0.5*cos(3*pi*x) + 0.2*sin(pi*x)'
modify y 'sin(2*pi*x)' 1
modify y 'cos(2*pi*x)' 2
origin 0 0
box
area y 'cbgGyr'

Pure C code

HMDT y = mgl_create_data_size(50,3,1);
mgl_data_modify(y,"0.7*sin(2*pi*x) + 0.5*cos(3*pi*x) + 0.2*sin(pi*x)",0);
mgl_data_modify(y,"sin(2*pi*x)",1);
mgl_data_modify(y,"cos(2*pi*x)",2);
mgl_set_origin(gr,0.,0.,0.);
mgl_box(gr,1);
mgl_area(gr,y,"cbgGyr");
mgl_delete_data(y);

Fortran code

integer y, mgl_create_data_size
y = mgl_create_data_size(50,3,1)
call mgl_data_modify(y,'0.7*sin(2*pi*x) + 0.5*cos(3*pi*x) + 0.2*sin(pi*x)',0)
call mgl_data_modify(y,'sin(2*pi*x)',1)
call mgl_data_modify(y,'cos(2*pi*x)',2)
call mgl_set_origin(gr,0.,0.,0.)
call mgl_box(gr,1)
call mgl_area(gr,y,'cbgGyr')
call mgl_delete_data(y)

Python

y = mglData(50,3);
y.Modify("0.7*sin(2*pi*x)+0.5*cos(3*pi*x)+0.2*sin(pi*x)",0);
y.Modify("sin(2*pi*x)",1);
y.Modify("cos(2*pi*x)",2);
gr.SetOrigin(0.,0.);
gr.Box();
gr.Area(y,"cbgGyr");

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.1.6 Bars sample

png/bars

C++ code

mglData y(10,3);
y.Modify("0.8*sin(pi*(2*x+y/2))+0.2*rnd");
gr->Org=mglPoint(0,0);
gr->Box();
gr->Bars(y);

MGL code

new y 10 3
modify y '0.8*sin(pi*(2*x+y/2))+0.2*rnd'
origin 0 0
box
bars y

Pure C code

HMDT y = mgl_create_data_size(10,3,1);
mgl_data_modify(y,"0.8*sin(pi*(2*x+y/2))+0.2*rnd");
mgl_set_origin(gr,0.,0.,0.);
mgl_box(gr,1);
mgl_bars(gr,y,NULL);
mgl_delete_data(y);

Fortran code

integer y, mgl_create_data_size
y = mgl_create_data_size(10,3,1)
call mgl_data_modify(y,'0.8*sin(pi*(2*x+y/2))+0.2*rnd')
call mgl_set_origin(gr,0.,0.,0.)
call mgl_box(gr,1)
call mgl_bars(gr,y,'')
call mgl_delete_data(y)

Python

y = mglData(10,3);
y.Modify("0.8*sin(pi*(2*x+y/2))+0.2*rnd");
gr.SetOrigin(0.,0.);
gr.Box();
gr.Bars(y);

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.1.7 Bars 2 colors sample

png/bars_2

C++ code

mglData y(10,3);
y.Modify("0.8*sin(pi*(2*x+y/2))+0.2*rnd");
gr->Org=mglPoint(0,0);
gr->Box();
gr->Bars(y,"cbgGyr");

MGL code

new y 10 3
modify y '0.8*sin(pi*(2*x+y/2))+0.2*rnd'
origin 0 0
box
bars y 'cbgGyr'

Pure C code

HMDT y = mgl_create_data_size(10,3,1);
mgl_data_modify(y,"0.8*sin(pi*(2*x+y/2))+0.2*rnd");
mgl_set_origin(gr,0.,0.,0.);
mgl_box(gr,1);
mgl_bars(gr,y,"cbgGyr");
mgl_delete_data(y);

Fortran code

integer y, mgl_create_data_size
y = mgl_create_data_size(10,3,1)
call mgl_data_modify(y,'0.8*sin(pi*(2*x+y/2))+0.2*rnd')
call mgl_set_origin(gr,0.,0.,0.)
call mgl_box(gr,1)
call mgl_bars(gr,y,'cbgGyr')
call mgl_delete_data(y)

Python

y = mglData(10,3);
y.Modify("0.8*sin(pi*(2*x+y/2))+0.2*rnd");
gr.SetOrigin(0.,0.);
gr.Box();
gr.Bars(y,"cbgGyr");

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.1.8 Bars above sample

png/bars_a

C++ code

mglData y(10,3);
y.Modify("0.8*sin(pi*(2*x+y/2))+0.2*rnd");
gr->Org=mglPoint(0,0);
gr->Box();
gr->Bars(y,"a");

MGL code

new y 10 3
modify y '0.8*sin(pi*(2*x+y/2))+0.2*rnd'
origin 0 0
box
bars y 'a'

Pure C code

HMDT y = mgl_create_data_size(10,3,1);
mgl_data_modify(y,"0.8*sin(pi*(2*x+y/2))+0.2*rnd");
mgl_set_origin(gr,0.,0.,0.);
mgl_box(gr,1);
mgl_bars(gr,y,"a");
mgl_delete_data(y);

Fortran code

integer y, mgl_create_data_size
y = mgl_create_data_size(10,3,1)
call mgl_data_modify(y,'0.8*sin(pi*(2*x+y/2))+0.2*rnd')
call mgl_set_origin(gr,0.,0.,0.)
call mgl_box(gr,1)
call mgl_bars(gr,y,'a')
call mgl_delete_data(y)

Python

y = mglData(10,3);
y.Modify("0.8*sin(pi*(2*x+y/2))+0.2*rnd");
gr.SetOrigin(0.,0.);
gr.Box();
gr.Bars(y,"a");

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.1.9 Bars fall sample

png/bars_f

C++ code

mglData y(10,3);
y.Modify("0.8*sin(pi*(2*x+y/2))+0.2*rnd");
gr->Org=mglPoint(0,0);
gr->Box();
gr->Bars(y,"f");

MGL code

new y 10 3
modify y '0.8*sin(pi*(2*x+y/2))+0.2*rnd'
origin 0 0
box
bars y 'f'

Pure C code

HMDT y = mgl_create_data_size(10,3,1);
mgl_data_modify(y,"0.8*sin(pi*(2*x+y/2))+0.2*rnd");
mgl_set_origin(gr,0.,0.,0.);
mgl_box(gr,1);
mgl_bars(gr,y,"f");
mgl_delete_data(y);

Fortran code

integer y, mgl_create_data_size
y = mgl_create_data_size(10,3,1)
call mgl_data_modify(y,'0.8*sin(pi*(2*x+y/2))+0.2*rnd')
call mgl_set_origin(gr,0.,0.,0.)
call mgl_box(gr,1)
call mgl_bars(gr,y,'f')
call mgl_delete_data(y)

Python

y = mglData(10,3);
y.Modify("0.8*sin(pi*(2*x+y/2))+0.2*rnd");
gr.SetOrigin(0.,0.);
gr.Box();
gr.Bars(y,"f");

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.1.10 Barh sample

png/barh

C++ code

mglData y(10,3);
y.Modify("0.8*sin(pi*(2*x+y/2))+0.2*rnd");
gr->Org=mglPoint(0,0);
gr->Box();
gr->Barh(y);

MGL code

new y 10 3
modify y '0.8*sin(pi*(2*x+y/2))+0.2*rnd'
origin 0 0
box
barh y

Pure C code

HMDT y = mgl_create_data_size(10,3,1);
mgl_data_modify(y,"0.8*sin(pi*(2*x+y/2))+0.2*rnd");
mgl_set_origin(gr,0.,0.,0.);
mgl_box(gr,1);
mgl_barh(gr,y,NULL);
mgl_delete_data(y);

Fortran code

integer y, mgl_create_data_size
y = mgl_create_data_size(10,3,1)
call mgl_data_modify(y,'0.8*sin(pi*(2*x+y/2))+0.2*rnd')
call mgl_set_origin(gr,0.,0.,0.)
call mgl_box(gr,1)
call mgl_barh(gr,y,'')
call mgl_delete_data(y)

Python

y = mglData(10,3);
y.Modify("0.8*sin(pi*(2*x+y/2))+0.2*rnd");
gr.SetOrigin(0.,0.);
gr.Box();
gr.Barh(y);

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.1.11 Step sample

png/step

C++ code

mglData y(50,3);
y.Modify("0.7*sin(2*pi*x) + 0.5*cos(3*pi*x) + 0.2*sin(pi*x)",0);
y.Modify("sin(2*pi*x)",1);
y.Modify("cos(2*pi*x)",2);
gr->Box();
gr->Step(y);

MGL code

new y 50 3
modify y '0.7*sin(2*pi*x) + 0.5*cos(3*pi*x) + 0.2*sin(pi*x)'
modify y 'sin(2*pi*x)' 1
modify y 'cos(2*pi*x)' 2
box
step y

Pure C code

HMDT y = mgl_create_data_size(50,3,1);
mgl_data_modify(y,"0.7*sin(2*pi*x) + 0.5*cos(3*pi*x) + 0.2*sin(pi*x)",0);
mgl_data_modify(y,"sin(2*pi*x)",1);
mgl_data_modify(y,"cos(2*pi*x)",2);
mgl_box(gr,1);
mgl_step(gr,y,NULL);
mgl_delete_data(y);

Fortran code

integer y, mgl_create_data_size
y = mgl_create_data_size(50,3,1)
call mgl_data_modify(y,'0.7*sin(2*pi*x) + 0.5*cos(3*pi*x) + 0.2*sin(pi*x)',0)
call mgl_data_modify(y,'sin(2*pi*x)',1)
call mgl_data_modify(y,'cos(2*pi*x)',2)
call mgl_box(gr,1)
call mgl_step(gr,y,'')
call mgl_delete_data(y)

Python

y = mglData(50,3);
y.Modify("0.7*sin(2*pi*x)+0.5*cos(3*pi*x)+0.2*sin(pi*x)",0);
y.Modify("sin(2*pi*x)",1);
y.Modify("cos(2*pi*x)",2);
gr.Box();
gr.Step(y);

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.1.12 Stem sample

png/stem

C++ code

mglData y(50,3);
y.Modify("0.7*sin(2*pi*x) + 0.5*cos(3*pi*x) + 0.2*sin(pi*x)",0);
y.Modify("sin(2*pi*x)",1);
y.Modify("cos(2*pi*x)",2);
gr->Org=mglPoint(0,0);
gr->Box();
gr->Stem(y,"o");

MGL code

new y 50 3
modify y '0.7*sin(2*pi*x) + 0.5*cos(3*pi*x) + 0.2*sin(pi*x)'
modify y 'sin(2*pi*x)' 1
modify y 'cos(2*pi*x)' 2
origin 0 0
box
stem y 'o'

Pure C code

HMDT y = mgl_create_data_size(50,3,1);
mgl_data_modify(y,"0.7*sin(2*pi*x) + 0.5*cos(3*pi*x) + 0.2*sin(pi*x)",0);
mgl_data_modify(y,"sin(2*pi*x)",1);
mgl_data_modify(y,"cos(2*pi*x)",2);
mgl_set_origin(gr,0.,0.,0.);
mgl_box(gr,1);
mgl_stem(gr,y,"o");
mgl_delete_data(y);

Fortran code

integer y, mgl_create_data_size
y = mgl_create_data_size(50,3,1)
call mgl_data_modify(y,'0.7*sin(2*pi*x) + 0.5*cos(3*pi*x) + 0.2*sin(pi*x)',0)
call mgl_data_modify(y,'sin(2*pi*x)',1)
call mgl_data_modify(y,'cos(2*pi*x)',2)
call mgl_set_origin(gr,0.,0.,0.)
call mgl_box(gr,1)
call mgl_stem(gr,y,'o')
call mgl_delete_data(y)

Python

y = mglData(50,3);
y.Modify("0.7*sin(2*pi*x)+0.5*cos(3*pi*x)+0.2*sin(pi*x)",0);
y.Modify("sin(2*pi*x)",1);
y.Modify("cos(2*pi*x)",2);
gr.SetOrigin(0.,0.);
gr.Box();
gr.Stem(y,"o");

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.1.13 Region sample

png/region

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->Box();
gr->Region(y1,y2,"r");
gr->Plot(y1,"k2");
gr->Plot(y2,"k2");

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)'
box
region y1 y2 'r'
plot y1 'k2'
plot y2 'k2'

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_box(gr,1);
mgl_region(gr,y1,y2,"r",1);
mgl_plot(gr,y1,"k2");
mgl_plot(gr,y2,"k2");
mgl_delete_data(y1);
mgl_delete_data(y2);

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_box(gr,1);
call mgl_region(gr,y1,y2,'r',1);
call mgl_plot(gr,y1,'k2');
call mgl_plot(gr,y2,'k2');
call mgl_delete_data(y1);
call mgl_delete_data(y2);

Python

y1, y2, x = mglData(50), mglData(50), mglData(50);
y1.Modify("0.3*sin(2*pi*x)");
y2.Modify("0.5+0.3*cos(2*pi*x)");
gr.Box();
gr.Region(y1,y2,"r");
gr.Plot(y1,"k2");
gr.Plot(y2,"k2");

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.1.14 Region gradient sample

png/region_2

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->Box();
gr->Region(y1,y2,"yr");
gr->Plot(y1,"k2");
gr->Plot(y2,"k2");

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)'
box
region y1 y2 'yr'
plot y1 'k2'
plot y2 'k2'

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_box(gr,1);
mgl_region(gr,y1,y2,"yr",1);
mgl_plot(gr,y1,"k2");
mgl_plot(gr,y2,"k2");
mgl_delete_data(y1);
mgl_delete_data(y2);

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_box(gr,1);
call mgl_region(gr,y1,y2,'yr',1);
call mgl_plot(gr,y1,'k2');
call mgl_plot(gr,y2,'k2');
call mgl_delete_data(y1);
call mgl_delete_data(y2);

Python

y1, y2, x = mglData(50), mglData(50), mglData(50);
y1.Modify("0.3*sin(2*pi*x)");
y2.Modify("0.5+0.3*cos(2*pi*x)");
gr.Box();
gr.Region(y1,y2,"yr");
gr.Plot(y1,"k2");
gr.Plot(y2,"k2");

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.1.15 Error sample

png/error

C++ code

mglData y(50,1), x0(10), y0(10), ex(10), ey(10);
y.Modify("0.7*sin(2*pi*x) + 0.5*cos(3*pi*x) + 0.2*sin(pi*x)",0);
x0.Modify("2*x-1 + 0.1*rnd-0.05");
y0.Modify("0.7*sin(2*pi*x) + 0.5*cos(3*pi*x) + 0.2*sin(pi*x) + 0.2*rnd-0.1");
ey.Modify("0.2"); ex.Modify("0.1");
gr->Box();
gr->Plot(y);
gr->Error(x0,y0,ex,ey,"ko");

MGL code

new y 50
new x0 10
new y0 10
new ex 10
new ey 10
modify y '0.7*sin(2*pi*x) + 0.5*cos(3*pi*x) + 0.2*sin(pi*x)'
modify x0 '2*x-1 + 0.1*rnd-0.05'
modify y0 '0.7*sin(2*pi*x) + 0.5*cos(3*pi*x) + 0.2*sin(pi*x) + 0.2*rnd-0.1'
modify ey '0.2'
modify ex '0.1'
box
plot y
error x0 y0 ex ey 'ko'

Pure C code

HMDT y = mgl_create_data_size(50,1,1);
HMDT x0 = mgl_create_data_size(10,1,1);
HMDT y0 = mgl_create_data_size(10,1,1);
HMDT ex = mgl_create_data_size(10,1,1);
HMDT ey = mgl_create_data_size(10,1,1);
mgl_data_modify(y,"0.7*sin(2*pi*x) + 0.5*cos(3*pi*x) + 0.2*sin(pi*x)",0);
mgl_data_modify(x0,"2*x-1 + 0.1*rnd-0.05",0);
mgl_data_modify(y0,"0.7*sin(2*pi*x) + 0.5*cos(3*pi*x) + 0.2*sin(pi*x) + 0.2*rnd-0.1",0);
mgl_data_modify(ey,"0.2",0); mgl_data_modify(ex,"0.1",0);
mgl_box(gr,1);
mgl_plot(gr,y,NULL);
mgl_error_exy(gr,x0,y0,ex,ey,"ko");
mgl_delete_data(x0); mgl_delete_data(y0);
mgl_delete_data(ex); mgl_delete_data(ey);
mgl_delete_data(y);

Fortran code

integer y, x0, y0, ex, ey, mgl_create_data_size
y = mgl_create_data_size(50,3,1)
x0 = mgl_create_data_size(10,1,1)
y0 = mgl_create_data_size(10,1,1)
ex = mgl_create_data_size(10,1,1)
ey = mgl_create_data_size(10,1,1)
call mgl_data_modify(y,'0.7*sin(2*pi*x) + 0.5*cos(3*pi*x) + 0.2*sin(pi*x)',0)
call mgl_data_modify(x0,'2*x-1 + 0.1*rnd-0.05',0);
call mgl_data_modify(y0,'0.7*sin(2*pi*x) + 0.5*cos(3*pi*x) + &
                         0.2*sin(pi*x) + 0.2*rnd-0.1',0);
call mgl_data_modify(ey,'0.2',0)
call mgl_data_modify(ex,'0.1',0);
call mgl_box(gr,1)
call mgl_plot(gr,y,'')
call mgl_error_exy(gr,x0,y0,ex,ey,'ko')
call mgl_delete_data(x0)
call mgl_delete_data(y0)
call mgl_delete_data(ex)
call mgl_delete_data(ey)
call mgl_delete_data(y)

Python

y, x0, y0, ex, ey = mglData(50,1), mglData(10), mglData(10), mglData(10), mglData(10);
y.Modify("0.7*sin(2*pi*x)+0.5*cos(3*pi*x)+0.2*sin(pi*x)",0);
x0.Modify("2*x-1+0.1*rnd-0.05");
y0.Modify("0.7*sin(2*pi*x)+0.5*cos(3*pi*x)+0.2*sin(pi*x)+0.2*rnd-0.1");
ey.Modify("0.2");   ex.Modify("0.1");
gr.Box();           gr.Plot(y);
gr.Error(x0,y0,ex,ey,"ko");

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.1.16 BoxPlot sample

png/boxplot

C++ code

mglData a(10,7);
a.Modify("(2*rnd-1)^3/2");
gr->BoxPlot(a);
gr->Box();
gr->Plot(a," ko");

MGL code

new a 10 7
modify a '(2*rnd-1)^3/2'
boxplot a
box:plot a ' ko'

Pure C code

HMDT a = mgl_create_data_size(10,7,1);
mgl_data_modify(a,"(2*rnd-1)^3/2",0);
mgl_box(gr,1);
mgl_plot(gr,a," ko");
mgl_boxplot(gr,a,NULL);
mgl_delete_data(a);

Fortran code

integer a, mgl_create_data_size
y = mgl_create_data_size(10,7,1)
call mgl_data_modify(a,'(2*rnd-1)^3/2',0);
call mgl_box(gr,1)
call mgl_plot(gr,a,' ko')
call mgl_boxplot(gr,a,'')
call mgl_delete_data(a)

Python

a = mglData(10,7);
a.Modify("(2*rnd-1)^3/2");
gr.Box();
gr.Plot(a," ko");
gr.BoxPlot(a);

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.1.17 Mark sample

png/mark

C++ code

mglData y(50,3), y1(50);
y.Modify("0.7*sin(2*pi*x) + 0.5*cos(3*pi*x) + 0.2*sin(pi*x)",0);
y.Modify("sin(2*pi*x)",1);
y.Modify("cos(2*pi*x)",2);
y1.Modify("0.5+0.3*cos(2*pi*x)");
gr->Box();
gr->Mark(y,y1,"bs");

MGL code

new y 50 3
modify y '0.7*sin(2*pi*x) + 0.5*cos(3*pi*x) + 0.2*sin(pi*x)'
modify y 'sin(2*pi*x)' 1
modify y 'cos(2*pi*x)' 2
new y1 50
modify y1 '0.5+0.3*cos(2*pi*x)'
box
mark y y1 'bs'

Pure C code

HMDT y = mgl_create_data_size(50,3,1);
HMDT y1 = mgl_create_data_size(50,1,1);
mgl_data_modify(y,"0.7*sin(2*pi*x) + 0.5*cos(3*pi*x) + 0.2*sin(pi*x)",0);
mgl_data_modify(y,"sin(2*pi*x)",1);
mgl_data_modify(y,"cos(2*pi*x)",2);
mgl_data_modify(y1,"0.5+0.3*cos(2*pi*x)",0);
mgl_box(gr,1);
mgl_mark_y(gr,y,y1,"bs");
mgl_delete_data(y);
mgl_delete_data(y1);

Fortran code

integer y, y1, mgl_create_data_size
y = mgl_create_data_size(50,3,1)
y1 = mgl_create_data_size(50,1,1)
call mgl_data_modify(y,'0.7*sin(2*pi*x) + 0.5*cos(3*pi*x) + 0.2*sin(pi*x)',0)
call mgl_data_modify(y,'sin(2*pi*x)',1)
call mgl_data_modify(y,'cos(2*pi*x)',2)
call mgl_data_modify(y1,'0.5+0.3*cos(2*pi*x)',0)
call mgl_box(gr,1)
call mgl_mark_y(gr,y,y1,'bs')
call mgl_delete_data(y)
call mgl_delete_data(y1)

Python

y, y1 = mglData(50,3), mglData(50);
y.Modify("0.7*sin(2*pi*x)+0.5*cos(3*pi*x)+0.2*sin(pi*x)",0);
y.Modify("sin(2*pi*x)",1);     y.Modify("cos(2*pi*x)",2);
y1.Modify("0.5+0.3*cos(2*pi*x)");
gr.Box();
gr.Mark(y,y1,"bs");

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.1.18 TextMark sample

png/textmark

C++ code

mglData y(50,3), y1(50);
y.Modify("0.7*sin(2*pi*x) + 0.5*cos(3*pi*x) + 0.2*sin(pi*x)",0);
y.Modify("sin(2*pi*x)",1);
y.Modify("cos(2*pi*x)",2);
y1.Modify("0.5+0.3*cos(2*pi*x)");
gr->Box();
gr->TextMark(y,y1,"\\gamma");

MGL code

new y 50 3
modify y '0.7*sin(2*pi*x) + 0.5*cos(3*pi*x) + 0.2*sin(pi*x)'
modify y 'sin(2*pi*x)' 1
modify y 'cos(2*pi*x)' 2
new y1 50
modify y1 '0.5+0.3*cos(2*pi*x)'
box
textmark y y1 '\gamma'

Pure C code

HMDT y, y1;
y = mgl_create_data_size(50,3,1);
y1 = mgl_create_data_size(50,1,1);
mgl_data_modify(y,"0.7*sin(2*pi*x) + 0.5*cos(3*pi*x) + 0.2*sin(pi*x)",0);
mgl_data_modify(y,"sin(2*pi*x)",1);
mgl_data_modify(y,"cos(2*pi*x)",2);
mgl_data_modify(y1,"0.5+0.3*cos(2*pi*x)",0);
mgl_box(gr,1);
mgl_textmark_yr(gr,y,y1,"\\gamma","");
mgl_delete_data(y);
mgl_delete_data(y1);

Fortran code

integer y, y1, mgl_create_data_size
y = mgl_create_data_size(50,3,1)
y1 = mgl_create_data_size(50,1,1)
call mgl_data_modify(y,'0.7*sin(2*pi*x) + 0.5*cos(3*pi*x) + 0.2*sin(pi*x)',0)
call mgl_data_modify(y,'sin(2*pi*x)',1)
call mgl_data_modify(y,'cos(2*pi*x)',2)
call mgl_data_modify(y1,'0.5+0.3*cos(2*pi*x)',0)
call mgl_box(gr,1)
call mgl_textmark_yr(gr,y,y1,'\gamma','')
call mgl_delete_data(y)
call mgl_delete_data(y1)

Python

y, y1 = mglData(50,3), mglData(50);
y.Modify("0.7*sin(2*pi*x)+0.5*cos(3*pi*x)+0.2*sin(pi*x)",0);
y.Modify("sin(2*pi*x)",1);     y.Modify("cos(2*pi*x)",2);
y1.Modify("0.5+0.3*cos(2*pi*x)");
gr.Box();
gr.TextMark(y,y1,"\\gamma");

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.1.19 Tube sample

png/tube

C++ code

mglData y(50,3);
y.Modify("0.7*sin(2*pi*x) + 0.5*cos(3*pi*x) + 0.2*sin(pi*x)",0);
y.Modify("sin(2*pi*x)",1);
y.Modify("cos(2*pi*x)",2);
gr->Rotate(40,60);
gr->Light(true);
gr->Box();
gr->Tube(y,0.05);

MGL code

new y 50 3
modify y '0.7*sin(2*pi*x) + 0.5*cos(3*pi*x) + 0.2*sin(pi*x)'
modify y 'sin(2*pi*x)' 1
modify y 'cos(2*pi*x)' 2
rotate 40 60
light on
box
tube y 0.05

Pure C code

HMDT y = mgl_create_data_size(50,3,1);
mgl_data_modify(y,"0.7*sin(2*pi*x) + 0.5*cos(3*pi*x) + 0.2*sin(pi*x)",0);
mgl_data_modify(y,"sin(2*pi*x)",1);
mgl_data_modify(y,"cos(2*pi*x)",2);
mgl_rotate(gr,40.,60.,0.);
mgl_set_light(gr,1);
mgl_box(gr,1);
mgl_tube(gr,y,0.05,NULL);
mgl_delete_data(y);

Fortran code

integer y, mgl_create_data_size
y = mgl_create_data_size(50,3,1)
call mgl_data_modify(y,'0.7*sin(2*pi*x) + 0.5*cos(3*pi*x) + 0.2*sin(pi*x)',0)
call mgl_data_modify(y,'sin(2*pi*x)',1)
call mgl_data_modify(y,'cos(2*pi*x)',2)
call mgl_rotate(gr,40.,60.,0.)
call mgl_set_light(gr,1)
call mgl_box(gr,1)
call mgl_tube(gr,y,0.05,'')
call mgl_delete_data(y)

Python

y = mglData(50,3);
y.Modify("0.7*sin(2*pi*x)+0.5*cos(3*pi*x)+0.2*sin(pi*x)",0);
y.Modify("sin(2*pi*x)",1);  y.Modify("cos(2*pi*x)",2);
gr.Rotate(40,60);   gr.Light(True);    gr.Box();
gr.Tube(y,0.05);

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.1.20 Text sample

png/text

C++ code

mglData y(50,3);
y.Modify("0.7*sin(2*pi*x) + 0.5*cos(3*pi*x) + 0.2*sin(pi*x)",0);
y.Modify("sin(2*pi*x)",1);
y.Modify("cos(2*pi*x)",2);
gr->Box();
gr->Plot(y.SubData(-1,0));
gr->Text(y,"This is very long string drawn along a curve",":k");
gr->Text(y,"Another string drawn above a curve","T:r");

MGL code

new y 50 3
modify y '0.7*sin(2*pi*x) + 0.5*cos(3*pi*x) + 0.2*sin(pi*x)'
modify y 'sin(2*pi*x)' 1
modify y 'cos(2*pi*x)' 2
box
plot y(:,0)
text y 'This is very long string drawn along a curve' ':k'
text y 'Another string drawn above a curve' 'T:r'

Pure C code

HMDT y = mgl_create_data_size(50,1,1);
mgl_data_modify(y,"0.7*sin(2*pi*x) + 0.5*cos(3*pi*x) + 0.2*sin(pi*x)",0);
mgl_box(gr,1);
mgl_plot(gr,y,NULL);
mgl_text_y(gr,y,"This is very long string drawn along a curve",":k",-1.);
mgl_text_y(gr,y,"Another string drawn above a curve","T:r",-1.);
mgl_delete_data(y);

Fortran code

integer y, mgl_create_data_size
y = mgl_create_data_size(50,1,1)
call mgl_data_modify(y,'0.7*sin(2*pi*x) + 0.5*cos(3*pi*x) + 0.2*sin(pi*x)',0)
call mgl_box(gr,1)
call mgl_plot(gr,y,'')
call mgl_text_y(gr,y,'This is very long string drawn along a curve',':k',-1.)
call mgl_text_y(gr,y,'Another string drawn above a curve','T:r',-1.)
call mgl_delete_data(y)

Python

y = mglData(50,3);
y.Modify("0.7*sin(2*pi*x)+0.5*cos(3*pi*x)+0.2*sin(pi*x)",0);
y.Modify("sin(2*pi*x)",1);     y.Modify("cos(2*pi*x)",2);
gr.Box();
gr.Plot(y.SubData(-1,0));
gr.Text(y,"This is very long string drawn along a curve",":k");
gr.Text(y,"Another string drawn above a curve","T:r");

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.1.21 Torus sample

png/torus

C++ code

mglData y1(50), y2(50);
y1.Modify("0.5+0.3*cos(2*pi*x)");
y2.Modify("0.3*sin(2*pi*x)");
gr->Rotate(40,60);
gr->Light(true);
gr->Box();
gr->Torus(y1,y2,"pz");

MGL code

new y1 50
new y2 50
modify y1 '0.5+0.3*cos(2*pi*x)'
modify y2 '0.3*sin(2*pi*x)'
rotate 40 60
light on
box
torus y1 y2 'pz'

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.5+0.3*cos(2*pi*x)",0);
mgl_data_modify(y2,"0.3*sin(2*pi*x)",0);
mgl_rotate(gr,40.,60.,0.);
mgl_set_light(gr,1);
mgl_box(gr,1);
mgl_torus(gr,y1,y2,"pz");
mgl_delete_data(y1);
mgl_delete_data(y2);

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.5+0.3*cos(2*pi*x)",0);
call mgl_data_modify(y2,"0.3*sin(2*pi*x)",0);
call mgl_rotate(gr,40.,60.,0.)
call mgl_set_light(gr,1)
call mgl_box(gr,1)
call mgl_torus(gr,y1,y2,'pz')
call mgl_delete_data(y1)
call mgl_delete_data(y2)

Python

y1, y2 = mglData(50), mglData(50);
y1.Modify("0.5+0.3*cos(2*pi*x)");
y2.Modify("0.3*sin(2*pi*x)");
gr.Rotate(40,60);    gr.Light(True);
gr.Box();
gr.Torus(y1,y2,"pz");

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.1.22 Chart sample

png/chart

C++ code

mglData ch(7,2);
ch.Modify("rnd+0.1");
gr->Rotate(40,60);
gr->Light(true);
gr->Box();
gr->Chart(ch,"#");

MGL code

new ch 7 2
modify ch 'rnd+0.1'
rotate 40 60
light on
box
chart ch

Pure C code

HMDT ch = mgl_create_data_size(7,2,1);
mgl_data_modify(ch,"rnd+0.1",0);
mgl_rotate(gr,40.,60.,0.);
mgl_set_light(gr,1);
mgl_box(gr,1);
mgl_chart(gr,ch,"#");
mgl_delete_data(ch);

Fortran code

integer ch, mgl_create_data_size
ch = mgl_create_data_size(7,2,1)
call mgl_data_modify(ch,'rnd+0.1',0)
call mgl_rotate(gr,40.,60.,0.)
call mgl_set_light(gr,1)
call mgl_box(gr,1)
call mgl_chart(gr,ch,'#')
call mgl_delete_data(ch)

Python

ch = mglData(7,2);  ch.Modify("rnd+0.1");
gr.Rotate(40,60);   gr.Light(True);
gr.Box();
gr.Chart(ch,"#");

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.1.23 Pie chart sample

png/pie_chart

C++ code

mglData ch(7,2);
ch.Modify("rnd+0.1");
gr->Rotate(40,60);
gr->Light(true);
gr->SetFunc("(y+1)/2*cos(pi*x)","(y+1)/2*sin(pi*x)");
gr->Box();
gr->Chart(ch,"bgr cmy#");

MGL code

new ch 7 2
modify ch 'rnd+0.1'
rotate 40 60
light on
axis '(y+1)/2*cos(pi*x)' '(y+1)/2*sin(pi*x)' ''
box
chart ch 'bgr cmy#'

Pure C code

HMDT ch = mgl_create_data_size(7,2,1);
mgl_data_modify(ch,"rnd+0.1",0);
mgl_rotate(gr,40.,60.,0.);
mgl_set_light(gr,1);
mgl_set_func(gr,"(y+1)/2*cos(pi*x)","(y+1)/2*sin(pi*x)",0);
mgl_box(gr,1);
mgl_chart(gr,ch,"bgr cmy#");
mgl_delete_data(ch);

Fortran code

integer ch, mgl_create_data_size
ch = mgl_create_data_size(7,2,1)
call mgl_data_modify(ch,'rnd+0.1',0)
call mgl_rotate(gr,40.,60.,0.)
call mgl_set_light(gr,1)
call mgl_set_func(gr,'(y+1)/2*cos(pi*x)','(y+1)/2*sin(pi*x)','');
call mgl_box(gr,1)
call mgl_chart(gr,ch,'bgr cmy#')
call mgl_delete_data(ch)

Python

ch = mglData(7,2);  ch.Modify("rnd+0.1");
gr.Rotate(40,60);   gr.Light(True);
gr.SetFunc("(y+1)/2*cos(pi*x)","(y+1)/2*sin(pi*x)");
gr.Box();
gr.Chart(ch,"bgr cmy#");

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.1.24 Ring chart sample

png/ring_chart

C++ code

mglData ch(7,2);
ch.Modify("rnd+0.1");
gr->Rotate(40,60);
gr->Light(true);
gr->SetFunc("(y+2)/3*cos(pi*x)","(y+2)/3*sin(pi*x)");
gr->Box();
gr->Chart(ch,"bgr cmy#");

MGL code

new ch 7 2
modify ch 'rnd+0.1'
rotate 40 60
light on
axis '(y+2)/3*cos(pi*x)' '(y+2)/3*sin(pi*x)' ''
box
chart ch 'bgr cmy#'

Pure C code

HMDT ch = mgl_create_data_size(7,2,1);
mgl_data_modify(ch,"rnd+0.1",0);
mgl_rotate(gr,40.,60.,0.);
mgl_set_light(gr,1);
mgl_set_func(gr,"(y+2)/3*cos(pi*x)","(y+2)/3*sin(pi*x)",0);
mgl_box(gr,1);
mgl_chart(gr,ch,"bgr cmy#");
mgl_delete_data(ch);

Fortran code

integer ch, mgl_create_data_size
ch = mgl_create_data_size(7,2,1)
call mgl_data_modify(ch,'rnd+0.1',0)
call mgl_rotate(gr,40.,60.,0.)
call mgl_set_light(gr,1)
call mgl_set_func(gr,'(y+2)/3*cos(pi*x)','(y+2)/3*sin(pi*x)','');
call mgl_box(gr,1)
call mgl_chart(gr,ch,'bgr cmy#')
call mgl_delete_data(ch)

Python

ch = mglData(7,2);  ch.Modify("rnd+0.1");
gr.Rotate(40,60);   gr.Light(True);
gr.SetFunc("(y+2)/3*cos(pi*x)","(y+2)/3*sin(pi*x)");
gr.Box();
gr.Chart(ch,"bgr cmy#");

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.2 2D plotting samples


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.2.1 Surf sample

png/surf

C++ code

mglData a(50,40);
a.Modify("0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))");
gr->Rotate(40,60);
gr->Light(true);
gr->Box();
gr->Surf(a);

MGL code

new a 50 40
modify a '0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))'
rotate 40 60
light on
box
surf a

Pure C code

HMDT a = mgl_create_data_size(50,40,1);
mgl_data_modify(a,"0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))",0);
mgl_rotate(gr,40.,60.,0.);
mgl_set_light(gr,1);
mgl_box(gr,1);
mgl_surf(gr,a,0);
mgl_delete_data(a);

Fortran code

integer a, mgl_create_data_size
a = mgl_create_data_size(50,40,1);
call mgl_data_modify(a,"0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))",0);
call mgl_rotate(gr,40.,60.,0.)
call mgl_set_light(gr,1)
call mgl_box(gr,1)
call mgl_surf(gr,a,'')
call mgl_delete_data(a)

Python

a = mglData(50,40);
a.Modify("0.6*sin(2*pi*x)*sin(3*pi*y)+0.4*cos(3*pi*(x*y))");
gr.Rotate(40,60);   gr.Light(True);    gr.Box();
gr.Surf(a);

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.2.2 Transparent surface sample

png/surf_alpha

C++ code

mglData a(50,40);
a.Modify("0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))");
gr->Rotate(40,60);
gr->Light(true);
gr->Alpha(true);
gr->Box();
gr->Surf(a);

MGL code

new a 50 40
modify a '0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))'
rotate 40 60
light on
alpha on
box
surf a

Pure C code

HMDT a = mgl_create_data_size(50,40,1);
mgl_data_modify(a,"0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))",0);
mgl_rotate(gr,40.,60.,0.);
mgl_set_light(gr,1);
mgl_set_alpha(gr,1);
mgl_box(gr,1);
mgl_surf(gr,a,0);
mgl_delete_data(a);

Fortran code

integer a, mgl_create_data_size
a = mgl_create_data_size(50,40,1);
call mgl_data_modify(a,"0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))",0);
call mgl_rotate(gr,40.,60.,0.)
call mgl_set_light(gr,1)
call mgl_set_alpha(gr,1)
call mgl_box(gr,1)
call mgl_surf(gr,a,'')
call mgl_delete_data(a)

Python

a = mglData(50,40);
a.Modify("0.6*sin(2*pi*x)*sin(3*pi*y)+0.4*cos(3*pi*(x*y))");
gr.Rotate(40,60);   gr.Light(True);    gr.Box();
gr.Alpha(True);
gr.Surf(a);

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.2.3 Surface in fog sample

png/surf_fog

C++ code

mglData a(50,40);
a.Modify("0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))");
gr->Rotate(40,60);
gr->Light(true);
gr->Fog(1);
gr->Box();
gr->Surf(a);

MGL code

new a 50 40
modify a '0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))'
rotate 40 60
light on
fog 1
box
surf a

Pure C code

HMDT a = mgl_create_data_size(50,40,1);
mgl_data_modify(a,"0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))",0);
mgl_rotate(gr,40.,60.,0.);
mgl_set_light(gr,1);
mgl_set_fog(gr,1.,0.25);
mgl_box(gr,1);
mgl_surf(gr,a,0);
mgl_delete_data(a);

Fortran code

integer a, mgl_create_data_size
a = mgl_create_data_size(50,40,1);
call mgl_data_modify(a,"0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))",0);
call mgl_rotate(gr,40.,60.,0.)
call mgl_set_light(gr,1)
call mgl_set_fog(gr,1.,0.25)
call mgl_box(gr,1)
call mgl_surf(gr,a,'')
call mgl_delete_data(a)

Python

a = mglData(50,40);
a.Modify("0.6*sin(2*pi*x)*sin(3*pi*y)+0.4*cos(3*pi*(x*y))");
gr.Rotate(40,60);   gr.Light(True);    gr.Box();
gr.Fog(1);
gr.Surf(a);

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.2.4 Sharp colors sample

png/surf_sl

C++ code

mglData a(50,40);
a.Modify("0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))");
gr->Rotate(40,60);
gr->Light(true);
gr->Box();
gr->Surf(a,"BbcyrR|");

MGL code

new a 50 40
modify a '0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))'
rotate 40 60
light on
box
surf a 'BbcyrR|'

Pure C code

HMDT a = mgl_create_data_size(50,40,1);
mgl_data_modify(a,"0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))",0);
mgl_rotate(gr,40.,60.,0.);
mgl_set_light(gr,1);
mgl_box(gr,1);
mgl_surf(gr,a,"BbcyrR|");
mgl_delete_data(a);

Fortran code

integer a, mgl_create_data_size
a = mgl_create_data_size(50,40,1);
call mgl_data_modify(a,"0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))",0);
call mgl_rotate(gr,40.,60.,0.)
call mgl_set_light(gr,1)
call mgl_box(gr,1)
call mgl_surf(gr,a,'BbcyrR|')
call mgl_delete_data(a)

Python

a = mglData(50,40);
a.Modify("0.6*sin(2*pi*x)*sin(3*pi*y)+0.4*cos(3*pi*(x*y))");
gr.Rotate(40,60);   gr.Light(True);    gr.Box();
gr.Surf(a,"BbcyrR|");

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.2.5 Mesh sample

png/mesh

C++ code

mglData a(50,40);
a.Modify("0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))");
gr->Rotate(40,60);
gr->Box();
gr->Mesh(a);

MGL code

new a 50 40
modify a '0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))'
rotate 40 60
box
mesh a

Pure C code

HMDT a = mgl_create_data_size(50,40,1);
mgl_data_modify(a,"0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))",0);
mgl_rotate(gr,40.,60.,0.);
mgl_box(gr,1);
mgl_mesh(gr,a,0);
mgl_delete_data(a);

Fortran code

integer a, mgl_create_data_size
a = mgl_create_data_size(50,40,1);
call mgl_data_modify(a,"0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))",0);
call mgl_rotate(gr,40.,60.,0.)
call mgl_box(gr,1)
call mgl_mesh(gr,a,'')
call mgl_delete_data(a)

Python

a = mglData(50,40);
a.Modify("0.6*sin(2*pi*x)*sin(3*pi*y)+0.4*cos(3*pi*(x*y))");
gr.Rotate(40,60);   gr.Light(True);    gr.Box();
gr.Mesh(a);

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.2.6 Fall sample

png/fall

C++ code

mglData a(50,40);
a.Modify("0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))");
gr->Rotate(40,60);
gr->Box();
gr->Fall(a);

MGL code

new a 50 40
modify a '0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))'
rotate 40 60
box
fall a

Pure C code

HMDT a = mgl_create_data_size(50,40,1);
mgl_data_modify(a,"0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))",0);
mgl_rotate(gr,40.,60.,0.);
mgl_box(gr,1);
mgl_fall(gr,a,0);
mgl_delete_data(a);

Fortran code

integer a, mgl_create_data_size
a = mgl_create_data_size(50,40,1);
call mgl_data_modify(a,"0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))",0);
call mgl_rotate(gr,40.,60.,0.)
call mgl_box(gr,1)
call mgl_fall(gr,a,'')
call mgl_delete_data(a)

Python

a = mglData(50,40);
a.Modify("0.6*sin(2*pi*x)*sin(3*pi*y)+0.4*cos(3*pi*(x*y))");
gr.Rotate(40,60);   gr.Light(True);    gr.Box();
gr.Fall(a);

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.2.7 Belt sample

png/belt

C++ code

mglData a(50,40);
a.Modify("0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))");
gr->Rotate(40,60);
gr->Light(true);
gr->Box();
gr->Belt(a);

MGL code

new a 50 40
modify a '0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))'
rotate 40 60
light on
box
belt a

Pure C code

HMDT a = mgl_create_data_size(50,40,1);
mgl_data_modify(a,"0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))",0);
mgl_rotate(gr,40.,60.,0.);
mgl_set_light(gr,1);
mgl_box(gr,1);
mgl_belt(gr,a,0);
mgl_delete_data(a);

Fortran code

integer a, mgl_create_data_size
a = mgl_create_data_size(50,40,1);
call mgl_data_modify(a,"0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))",0);
call mgl_rotate(gr,40.,60.,0.)
call mgl_set_light(gr,1)
call mgl_box(gr,1)
call mgl_belt(gr,a,'')
call mgl_delete_data(a)

Python

a = mglData(50,40);
a.Modify("0.6*sin(2*pi*x)*sin(3*pi*y)+0.4*cos(3*pi*(x*y))");
gr.Rotate(40,60);   gr.Light(True);    gr.Box();
gr.Belt(a);

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.2.8 Tile sample

png/tile

C++ code

mglData a(50,40);
a.Modify("0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))");
gr->Rotate(40,60);
gr->Light(true);
gr->Box();
gr->Tile(a);

MGL code

new a 50 40
modify a '0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))'
rotate 40 60
light on
box
tile a

Pure C code

HMDT a = mgl_create_data_size(50,40,1);
mgl_data_modify(a,"0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))",0);
mgl_rotate(gr,40.,60.,0.);
mgl_set_light(gr,1);
mgl_box(gr,1);
mgl_tile(gr,a,0);
mgl_delete_data(a);

Fortran code

integer a, mgl_create_data_size
a = mgl_create_data_size(50,40,1);
call mgl_data_modify(a,"0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))",0);
call mgl_rotate(gr,40.,60.,0.)
call mgl_set_light(gr,1)
call mgl_box(gr,1)
call mgl_tile(gr,a,'')
call mgl_delete_data(a)

Python

a = mglData(50,40);
a.Modify("0.6*sin(2*pi*x)*sin(3*pi*y)+0.4*cos(3*pi*(x*y))");
gr.Rotate(40,60);   gr.Light(True);    gr.Box();
gr.Tile(a);

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.2.9 Boxs sample

png/boxs

C++ code

mglData a(50,40);
a.Modify("0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))");
gr->Rotate(40,60);  gr->Light(true);
gr->Org = mglPoint(0,0,0);
gr->Box();
gr->Boxs(a);

MGL code

new a 50 40
modify a '0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))'
rotate 40 60
light on
origin 0 0 0
box
boxs a

Pure C code

HMDT a = mgl_create_data_size(50,40,1);
mgl_data_modify(a,"0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))",0);
mgl_rotate(gr,40.,60.,0.);
mgl_set_light(gr,1);
mgl_set_origin(gr,0.,0.,0.);
mgl_box(gr,1);
mgl_boxs(gr,a,0,0.);
mgl_delete_data(a);

Fortran code

integer a, mgl_create_data_size
a = mgl_create_data_size(50,40,1);
call mgl_data_modify(a,"0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))",0);
call mgl_rotate(gr,40.,60.,0.)
call mgl_set_light(gr,1)
call mgl_set_origin(gr,0.,0.,0.);
call mgl_box(gr,1)
call mgl_boxs(gr,a,'',0.)
call mgl_delete_data(a)

Python

a = mglData(50,40);
a.Modify("0.6*sin(2*pi*x)*sin(3*pi*y)+0.4*cos(3*pi*(x*y))");
gr.Rotate(40,60);       gr.Light(True);
gr.SetOrigin(0.,0.,0.); gr.Box();
gr.Boxs(a);

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.2.10 Dens sample

png/dens

C++ code

mglData a(50,40);
a.Modify("0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))");
gr->Box();
gr->Dens(a);
gr->Colorbar();

MGL code

new a 50 40
modify a '0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))'
box
dens a
colorbar

Pure C code

HMDT a = mgl_create_data_size(50,40,1);
mgl_data_modify(a,"0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))",0);
mgl_box(gr,1);
mgl_dens(gr,a,0,0);
mgl_colorbar(gr,"",0);
mgl_delete_data(a);

Fortran code

integer a, mgl_create_data_size
a = mgl_create_data_size(50,40,1);
call mgl_data_modify(a,"0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))",0);
call mgl_box(gr,1)
call mgl_dens(gr,a,'',0)
call mgl_colorbar(gr,'',0)
call mgl_delete_data(a)

Python

a = mglData(50,40);
a.Modify("0.6*sin(2*pi*x)*sin(3*pi*y)+0.4*cos(3*pi*(x*y))");
gr.Box();
gr.Dens(a);
gr.Colorbar();

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.2.11 Cont sample

png/cont

C++ code

mglData a(50,40);
a.Modify("0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))");
gr->Rotate(40,60);
gr->Box();
gr->Cont(a);

MGL code

new a 50 40
modify a '0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))'
rotate 40 60
box
cont a

Pure C code

HMDT a = mgl_create_data_size(50,40,1);
mgl_data_modify(a,"0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))",0);
mgl_rotate(gr,40.,60.,0.);
mgl_box(gr,1);
mgl_cont(gr,a,0,7,NAN);
mgl_delete_data(a);

Fortran code

integer a, mgl_create_data_size
real zero, nan
! I don't know the NaN symbol in Fortran. So I produce it as zero/zero
zero = 0; nan = zero/zero 
a = mgl_create_data_size(50,40,1);
call mgl_data_modify(a,"0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))",0);
call mgl_rotate(gr,40.,60.,0.)
call mgl_box(gr,1)
call mgl_cont(gr,a,'',7,nan)
call mgl_delete_data(a)

Python

a = mglData(50,40);
a.Modify("0.6*sin(2*pi*x)*sin(3*pi*y)+0.4*cos(3*pi*(x*y))");
gr.Rotate(40,60);
gr.Box();
gr.Cont(a);

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.2.12 ContF sample

png/contf

C++ code

mglData a(50,40);
a.Modify("0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))");
gr->Rotate(40,60);  gr->Light(true);
gr->Box();
gr->ContF(a);

MGL code

new a 50 40
modify a '0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))'
rotate 40 60
light on
box
contf a

Pure C code

HMDT a = mgl_create_data_size(50,40,1);
mgl_data_modify(a,"0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))",0);
mgl_rotate(gr,40.,60.,0.);
mgl_set_light(gr,1);
mgl_box(gr,1);
mgl_contf(gr,a,0,7,NAN);
mgl_delete_data(a);

Fortran code

integer a, mgl_create_data_size
real zero, nan
! I don't know the NaN symbol in Fortran. So I produce it as zero/zero
zero = 0; nan = zero/zero
a = mgl_create_data_size(50,40,1);
call mgl_data_modify(a,"0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))",0);
call mgl_rotate(gr,40.,60.,0.)
call mgl_set_light(gr,1)
call mgl_box(gr,1)
call mgl_contf(gr,a,'',7,nan)
call mgl_delete_data(a)

Python

a = mglData(50,40);
a.Modify("0.6*sin(2*pi*x)*sin(3*pi*y)+0.4*cos(3*pi*(x*y))");
gr.Rotate(40,60);   gr.Light(True);
gr.Box();
gr.ContF(a);

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.2.13 ContD sample

png/contd

C++ code

mglData a(50,40), v(9);
a.Modify("0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))");
v.Fill(-1,1);
gr->Box();
gr->ContD(v,a);
gr->Colorbar(v);

MGL code

new a 50 40
modify a '0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))'
var v 9 -1 1
box
contd v a
colorbar v

Pure C code

HMDT a = mgl_create_data_size(50,40,1);
HMDT v = mgl_create_data_size(9,1,1);
mgl_data_modify(a,"0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))",0);
mgl_data_fill(v,-1.,1.,'x');
mgl_box(gr,1);
mgl_contd_val(gr,v,a,0,0);
mgl_colorbar_val(gr,v,NULL,0);
mgl_delete_data(a);
mgl_delete_data(v);

Fortran code

integer a, v, mgl_create_data_size
a = mgl_create_data_size(50,40,1);
v = mgl_create_data_size(9,1,1);
call mgl_data_modify(a,"0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))",0);
call mgl_data_fill(v,-1.,1.,'x');
call mgl_box(gr,1)
call mgl_contd_val(gr,v,a,'',0);
call mgl_colorbar_val(gr,v,NULL,0);
call mgl_delete_data(a)
call mgl_delete_data(v)

Python

a, v = mglData(50,40), mglData(9);
a.Modify("0.6*sin(2*pi*x)*sin(3*pi*y)+0.4*cos(3*pi*(x*y))");
v.Fill(-1,1);
gr.Box();
gr.ContD(v,a);
gr.Colorbar(v);

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.2.14 Axial sample

png/axial

C++ code

mglData a(50,40);
a.Modify("0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))");
gr->Rotate(40,60);
gr->Light(true);
gr->Alpha(true);
gr->Box();
gr->Axial(a);

MGL code

new a 50 40
modify a '0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))'
rotate 40 60
light on
alpha on
box
axial a

Pure C code

HMDT a = mgl_create_data_size(50,40,1);
mgl_data_modify(a,"0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))",0);
mgl_rotate(gr,40.,60.,0.);
mgl_set_light(gr,1);
mgl_set_alpha(gr,1);
mgl_box(gr,1);
mgl_axial(gr,a,"",3);
mgl_delete_data(a);

Fortran code

integer a, mgl_create_data_size
a = mgl_create_data_size(50,40,1);
call mgl_data_modify(a,"0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))",0);
call mgl_rotate(gr,40.,60.,0.)
call mgl_set_light(gr,1)
call mgl_set_alpha(gr,1)
call mgl_box(gr,1)
call mgl_axial(gr,a,'',3)
call mgl_delete_data(a)

Python

a = mglData(50,40);
a.Modify("0.6*sin(2*pi*x)*sin(3*pi*y)+0.4*cos(3*pi*(x*y))");
gr.Rotate(40,60);   gr.Light(True);    gr.Alpha(True);
gr.Box();
gr.Axial(a);

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.2.15 Grad sample

png/grad

C++ code

mglData a(50,40);
a.Modify("0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))");
gr->Box();  gr->Alpha(true);    gr->Dens(a);
gr->Grad(a);

MGL code

new a 50 40
modify a '0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))'
box:alpha on:dens a
grad a

Pure C code

HMDT a = mgl_create_data_size(50,40,1);
mgl_data_modify(a,"0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))",0);
mgl_box(gr,1);
mgl_set_alpha(gr,1);
mgl_dens(gr,a,0,0);
mgl_grad(gr,a,0,0);
mgl_delete_data(a);

Fortran code

integer a, mgl_create_data_size
a = mgl_create_data_size(50,40,1);
call mgl_data_modify(a,"0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))",0);
call mgl_box(gr,1)
call mgl_set_alpha(gr,1)
call mgl_dens(gr,a,'',0)
call mgl_grad(gr,a,'',0)
call mgl_delete_data(a)

Python

a = mglData(50,40);
a.Modify("0.6*sin(2*pi*x)*sin(3*pi*y)+0.4*cos(3*pi*(x*y))");
gr.Box();   gr.Alpha(1);    gr.Dens(a);
gr.Colorbar();

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.3 3D plotting samples


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.3.1 Surf3 sample

png/surf3

C++ code

mglData a(60,50,40);
a.Modify("-2*((2*x-1)^2 + (2*y-1)^2 + (2*z-1)^4 - (2*z-1)^2 - 0.1)");
gr->Rotate(40,60);
gr->Light(true);
gr->Alpha(true);
gr->Box();
gr->Surf3(a);

MGL code

new a 60 50 40
modify a '-2*((2*x-1)^2 + (2*y-1)^2 + (2*z-1)^4 - (2*z-1)^2 - 0.1)'
rotate 40 60
light on
alpha on
box
surf3 a

Pure C code

HMDT a = mgl_create_data_size(60,50,40);
mgl_data_modify(a,"-2*((2*x-1)^2 + (2*y-1)^2 + (2*z-1)^4 - (2*z-1)^2 - 0.1)",0);
mgl_rotate(gr,40.,60.,0.);
mgl_set_light(gr,1);
mgl_set_alpha(gr,1);
mgl_box(gr,1);
mgl_surf3(gr,a,0,3);
mgl_delete_data(a);

Fortran code

integer a, mgl_create_data_size
a = mgl_create_data_size(60,50,40);
call mgl_data_modify(a,"-2*((2*x-1)^2 + (2*y-1)^2 + (2*z-1)^4 - (2*z-1)^2 - 0.1)",0);
call mgl_rotate(gr,40.,60.,0.)
call mgl_set_light(gr,1)
call mgl_set_alpha(gr,1)
call mgl_box(gr,1)
call mgl_surf3(gr,a,'',3)
call mgl_delete_data(a)

Python

a = mglData(60,50,40);
a.Modify("-2*((2*x-1)^2 + (2*y-1)^2 + (2*z-1)^4 - (2*z-1)^2 - 0.1)");
gr.Rotate(40,60);   gr.Light(True);    gr.Alpha(True);
gr.Box();
gr.Surf3(a);

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.3.2 Cloud sample

png/cloud

C++ code

mglData a(60,50,40);
a.Modify("-2*((2*x-1)^2 + (2*y-1)^2 + (2*z-1)^4 - (2*z-1)^2 - 0.1)");
gr->Rotate(40,60);
gr->Alpha(true);
gr->Box();
gr->Cloud(a,"wyrRk");

MGL code

new a 60 50 40
modify a '-2*((2*x-1)^2 + (2*y-1)^2 + (2*z-1)^4 - (2*z-1)^2 - 0.1)'
rotate 40 60
alpha on
box
cloud a 'wyrRk'

Pure C code

HMDT a = mgl_create_data_size(60,50,40);
mgl_data_modify(a,"-2*((2*x-1)^2 + (2*y-1)^2 + (2*z-1)^4 - (2*z-1)^2 - 0.1)",0);
mgl_rotate(gr,40.,60.,0.);
mgl_set_alpha(gr,1);
mgl_box(gr,1);
mgl_cloud(gr,a,"wyrRk",1.);
mgl_delete_data(a);

Fortran code

integer a, mgl_create_data_size
a = mgl_create_data_size(60,50,40);
call mgl_data_modify(a,"-2*((2*x-1)^2 + (2*y-1)^2 + (2*z-1)^4 - (2*z-1)^2 - 0.1)",0);
call mgl_rotate(gr,40.,60.,0.)
call mgl_set_alpha(gr,1)
call mgl_box(gr,1)
call mgl_cloud(gr,a,'wyrRk',1.)
call mgl_delete_data(a)

Python

a = mglData(60,50,40);
a.Modify("-2*((2*x-1)^2 + (2*y-1)^2 + (2*z-1)^4 - (2*z-1)^2 - 0.1)");
gr.Rotate(40,60);   gr.Alpha(True);
gr.Box();
gr.Cloud(a,"wyrRk");

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.3.3 CloudP sample

png/cloudp

C++ code

mglData a(60,50,40);
a.Modify("-2*((2*x-1)^2 + (2*y-1)^2 + (2*z-1)^4 - (2*z-1)^2 - 0.1)");
gr->Rotate(40,60);
gr->Alpha(true);
gr->Box();
gr->CloudP(a,"wyrRk");

MGL code Not available. Pure C code

HMDT a = mgl_create_data_size(60,50,40);
mgl_data_modify(a,"-2*((2*x-1)^2 + (2*y-1)^2 + (2*z-1)^4 - (2*z-1)^2 - 0.1)",0);
mgl_rotate(gr,40.,60.,0.);
mgl_set_alpha(gr,1);
mgl_box(gr,1);
mgl_cloudp(gr,a,"wyrRk",1.);
mgl_delete_data(a);

Fortran code

integer a, mgl_create_data_size
a = mgl_create_data_size(60,50,40);
call mgl_data_modify(a,"-2*((2*x-1)^2 + (2*y-1)^2 + (2*z-1)^4 - (2*z-1)^2 - 0.1)",0);
call mgl_rotate(gr,40.,60.,0.)
call mgl_set_alpha(gr,1)
call mgl_box(gr,1)
call mgl_cloudp(gr,a,'wyrRk',1.)
call mgl_delete_data(a)

Python Not available.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.3.4 Dens3 sample

png/densa

C++ code

mglData a(60,50,40);
a.Modify("-2*((2*x-1)^2 + (2*y-1)^2 + (2*z-1)^4 - (2*z-1)^2 - 0.1)");
gr->Rotate(40,60);  gr->Alpha(true);    gr->Org = mglPoint(0,0,0);
gr->Box();
gr->DensA(a);
gr->Axis();

MGL code

new a 60 50 40
modify a '-2*((2*x-1)^2 + (2*y-1)^2 + (2*z-1)^4 - (2*z-1)^2 - 0.1)'
rotate 40 60
alpha on
origin 0 0 0
box
densa a
axis

Pure C code

HMDT a = mgl_create_data_size(60,50,40);
mgl_data_modify(a,"-2*((2*x-1)^2 + (2*y-1)^2 + (2*z-1)^4 - (2*z-1)^2 - 0.1)",0);
mgl_rotate(gr,40.,60.,0.);
mgl_set_alpha(gr,1);
mgl_set_origin(gr,0.,0.,0.);
mgl_box(gr,1);
mgl_dens3_all(gr,a,0);
mgl_axis(gr,"xyz");
mgl_delete_data(a);

Fortran code

integer a, mgl_create_data_size
a = mgl_create_data_size(60,50,40);
call mgl_data_modify(a,"-2*((2*x-1)^2 + (2*y-1)^2 + (2*z-1)^4 - (2*z-1)^2 - 0.1)",0);
call mgl_rotate(gr,40.,60.,0.)
call mgl_set_alpha(gr,1)
call mgl_set_origin(gr,0.,0.,0.);
call mgl_box(gr,1)
call mgl_dens3_all(gr,a,'')
call mgl_axis(gr,"xyz")
call mgl_delete_data(a)

Python

a = mglData(60,50,40);
a.Modify("-2*((2*x-1)^2 + (2*y-1)^2 + (2*z-1)^4 - (2*z-1)^2 - 0.1)");
gr.Rotate(40,60);       gr.Alpha(True);
gr.SetOrigin(0,0,0);    gr.Box();
gr.Axis();
gr.DensA(a);

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.3.5 Cont3 sample

png/conta

C++ code

mglData a(60,50,40);
a.Modify("-2*((2*x-1)^2 + (2*y-1)^2 + (2*z-1)^4 - (2*z-1)^2 - 0.1)");
gr->Rotate(40,60);
gr->Box();
gr->ContA(a);

MGL code

new a 60 50 40
modify a '-2*((2*x-1)^2 + (2*y-1)^2 + (2*z-1)^4 - (2*z-1)^2 - 0.1)'
rotate 40 60
box
conta a

Pure C code

HMDT a = mgl_create_data_size(60,50,40);
mgl_data_modify(a,"-2*((2*x-1)^2 + (2*y-1)^2 + (2*z-1)^4 - (2*z-1)^2 - 0.1)",0);
mgl_rotate(gr,40.,60.,0.);
mgl_box(gr,1);
mgl_cont_all(gr,a,0,7);
mgl_delete_data(a);

Fortran code

integer a, mgl_create_data_size
a = mgl_create_data_size(60,50,40);
call mgl_data_modify(a,"-2*((2*x-1)^2 + (2*y-1)^2 + (2*z-1)^4 - (2*z-1)^2 - 0.1)",0);
call mgl_rotate(gr,40.,60.,0.)
call mgl_box(gr,1)
call mgl_cont_all(gr,a,'',7)
call mgl_delete_data(a)

Python

a = mglData(60,50,40);
a.Modify("-2*((2*x-1)^2 + (2*y-1)^2 + (2*z-1)^4 - (2*z-1)^2 - 0.1)");
gr.Rotate(40,60);
gr.Box();
gr.ContA(a);

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.3.6 ContF3 sample

png/contfa

C++ code

mglData a(60,50,40);
a.Modify("-2*((2*x-1)^2 + (2*y-1)^2 + (2*z-1)^4 - (2*z-1)^2 - 0.1)");
gr->Rotate(40,60);  gr->Light(true);
gr->Box();
gr->ContFA(a);

MGL code

new a 60 50 40
modify a '-2*((2*x-1)^2 + (2*y-1)^2 + (2*z-1)^4 - (2*z-1)^2 - 0.1)'
rotate 40 60
light on
box
contfa a

Pure C code

HMDT a = mgl_create_data_size(60,50,40);
mgl_data_modify(a,"-2*((2*x-1)^2 + (2*y-1)^2 + (2*z-1)^4 - (2*z-1)^2 - 0.1)",0);
mgl_rotate(gr,40.,60.,0.);
mgl_set_light(gr,1);
mgl_box(gr,1);
mgl_contf_all(gr,a,0,7);
mgl_delete_data(a);

Fortran code

integer a, mgl_create_data_size
a = mgl_create_data_size(60,50,40);
call mgl_data_modify(a,"-2*((2*x-1)^2 + (2*y-1)^2 + (2*z-1)^4 - (2*z-1)^2 - 0.1)",0);
call mgl_rotate(gr,40.,60.,0.)
call mgl_set_light(gr,1)
call mgl_box(gr,1)
call mgl_contf_all(gr,a,'',7)
call mgl_delete_data(a)

Python

a = mglData(60,50,40);
a.Modify("-2*((2*x-1)^2 + (2*y-1)^2 + (2*z-1)^4 - (2*z-1)^2 - 0.1)");
gr.Rotate(40,60);   gr.Light(True);
gr.Box();
gr.ContFA(a);

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.3.7 Cont projection sample

png/cont_xyz

C++ code

mglData a(60,50,40);
a.Modify("-2*((2*x-1)^2 + (2*y-1)^2 + (2*z-1)^4 - (2*z-1)^2 - 0.1)");
gr->Rotate(40,60);
gr->Box();
gr->ContX(a.Sum("x"),"",-1);
gr->ContY(a.Sum("y"),"",1);
gr->ContZ(a.Sum("z"),"",-1);

MGL code

new a 60 50 40
modify a '-2*((2*x-1)^2 + (2*y-1)^2 + (2*z-1)^4 - (2*z-1)^2 - 0.1)'
rotate 40 60
box
sum s a 'x'
contx s '' -1
sum s a 'y'
conty s '' 1
sum s a 'z'
contz s '' -1

Pure C code

HMDT a = mgl_create_data_size(60,50,40), s;
mgl_data_modify(a,"-2*((2*x-1)^2 + (2*y-1)^2 + (2*z-1)^4 - (2*z-1)^2 - 0.1)",0);
mgl_rotate(gr,40.,60.,0.);
mgl_box(gr,1);
s=mgl_data_sum(a,"x"); mgl_cont_x(gr,s,0,-1.,7); mgl_delete_data(s);
s=mgl_data_sum(a,"y"); mgl_cont_y(gr,s,0,1.,7); mgl_delete_data(s);
s=mgl_data_sum(a,"z"); mgl_cont_z(gr,s,0,-1.,7); mgl_delete_data(s);
mgl_delete_data(a);

Fortran code

integer a,s, mgl_create_data_size, mgl_data_sum
a = mgl_create_data_size(60,50,40);
call mgl_data_modify(a,"-2*((2*x-1)^2 + (2*y-1)^2 + (2*z-1)^4 - (2*z-1)^2 - 0.1)",0);
call mgl_rotate(gr,40.,60.,0.)
call mgl_box(gr,1)
s=mgl_data_sum(a,'x')
call mgl_cont_x(gr,s,'',-1.,7)
call mgl_delete_data(s)
s=mgl_data_sum(a,'y')
call mgl_cont_y(gr,s,'',1.,7)
call mgl_delete_data(s)
s=mgl_data_sum(a,'z')
call mgl_cont_z(gr,s,'',-1.,7)
call mgl_delete_data(s)
call mgl_delete_data(a)

Python

a = mglData(60,50,40);
a.Modify("-2*((2*x-1)^2 + (2*y-1)^2 + (2*z-1)^4 - (2*z-1)^2 - 0.1)");
gr.Rotate(40,60);               gr.Box();
gr.ContX(a.Sum("x"),"",-1);
gr.ContY(a.Sum("y"),"",1);
gr.ContZ(a.Sum("z"),"",-1);

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.3.8 Dens projection sample

png/dens_xyz

C++ code

mglData a(60,50,40);
a.Modify("-2*((2*x-1)^2 + (2*y-1)^2 + (2*z-1)^4 - (2*z-1)^2 - 0.1)");
gr->Rotate(40,60);
gr->Box();
gr->DensX(a.Sum("x"),"",-1);
gr->DensY(a.Sum("y"),"",1);
gr->DensZ(a.Sum("z"),"",-1);

MGL code

new a 60 50 40
modify a '-2*((2*x-1)^2 + (2*y-1)^2 + (2*z-1)^4 - (2*z-1)^2 - 0.1)'
rotate 40 60
box
sum s a 'x'
densx s '' -1
sum s a 'y'
densy s '' 1
sum s a 'z'
densz s '' -1

Pure C code

HMDT a, s; a = mgl_create_data_size(60,50,40);
mgl_data_modify(a,"-2*((2*x-1)^2 + (2*y-1)^2 + (2*z-1)^4 - (2*z-1)^2 - 0.1)",0);
mgl_rotate(gr,40.,60.,0.);
mgl_box(gr,1);
s=mgl_data_sum(a,"x"); mgl_dens_x(gr,s,0,-1.); mgl_delete_data(s);
s=mgl_data_sum(a,"y"); mgl_dens_y(gr,s,0,1.); mgl_delete_data(s);
s=mgl_data_sum(a,"z"); mgl_dens_z(gr,s,0,-1.); mgl_delete_data(s);
mgl_delete_data(a);

Fortran code

integer a,s, mgl_create_data_size, mgl_data_sum
a = mgl_create_data_size(60,50,40);
call mgl_data_modify(a,"-2*((2*x-1)^2 + (2*y-1)^2 + (2*z-1)^4 - (2*z-1)^2 - 0.1)",0);
call mgl_rotate(gr,40.,60.,0.)
call mgl_box(gr,1)
s=mgl_data_sum(a,'x')
call mgl_dens_x(gr,s,'',-1.)
call mgl_delete_data(s)
s=mgl_data_sum(a,'y')
call mgl_dens_y(gr,s,'',1.)
call mgl_delete_data(s)
s=mgl_data_sum(a,'z')
call mgl_dens_z(gr,s,'',-1.)
call mgl_delete_data(s)
call mgl_delete_data(a)

Python

a = mglData(60,50,40);
a.Modify("-2*((2*x-1)^2 + (2*y-1)^2 + (2*z-1)^4 - (2*z-1)^2 - 0.1)");
gr.Rotate(40,60);               gr.Box();
gr.DensX(a.Sum("x"),"",-1);
gr.DensY(a.Sum("y"),"",1);
gr.DensZ(a.Sum("z"),"",-1);

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.3.9 CutMinMax sample

png/cutminmax

C++ code

mglData a(60,50,40);
a.Modify("-2*((2*x-1)^2 + (2*y-1)^2 + (2*z-1)^4 - (2*z-1)^2 - 0.1)");
gr->Rotate(40,60);
gr->Light(true);
gr->Alpha(true);
gr->CutMin = mglPoint(0,-1,-1); gr->CutMax = mglPoint(1,0,1);
gr->Box();
gr->Surf3(a);

MGL code

new a 60 50 40
modify a '-2*((2*x-1)^2 + (2*y-1)^2 + (2*z-1)^4 - (2*z-1)^2 - 0.1)'
rotate 40 60
light on
alpha on
cut 0 -1 -1 1 0 1
box
surf3 a

Pure C code

HMDT a = mgl_create_data_size(60,50,40);
mgl_data_modify(a,"-2*((2*x-1)^2 + (2*y-1)^2 + (2*z-1)^4 - (2*z-1)^2 - 0.1)",0);
mgl_rotate(gr,40.,60.,0.);
mgl_set_light(gr,1);
mgl_set_alpha(gr,1);
mgl_set_cut_box(gr,0.,-1.,-1.,1.,0.,1.);
mgl_box(gr,1);
mgl_surf3(gr,a,0,3);
mgl_delete_data(a);

Fortran code

integer a, mgl_create_data_size
a = mgl_create_data_size(60,50,40);
call mgl_data_modify(a,"-2*((2*x-1)^2 + (2*y-1)^2 + (2*z-1)^4 - (2*z-1)^2 - 0.1)",0);
call mgl_rotate(gr,40.,60.,0.)
call mgl_set_light(gr,1)
call mgl_set_alpha(gr,1)
call mgl_set_cut_box(gr,0.,-1.,-1.,1.,0.,1.);
call mgl_box(gr,1)
call mgl_surf3(gr,a,'',3)
call mgl_delete_data(a)

Python

a = mglData(60,50,40);
a.Modify("-2*((2*x-1)^2 + (2*y-1)^2 + (2*z-1)^4 - (2*z-1)^2 - 0.1)");
gr.Rotate(40,60);   gr.Light(True);    gr.Alpha(True);
gr.SetCutBox(0,-1,-1,1,0,1);    gr.Box();
gr.Surf3(a);

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.3.10 “Isocaps” sample

png/cutminmax2

C++ code

mglData a(61,51,40);
a.Modify("-2*((2*x-1)^2 + (2*y-1)^2 + (2*z-1)^4 - (2*z-1)^2 - 0.1)");
gr->Rotate(40,60);
gr->Light(true);
gr->CutMin = mglPoint(0,-1,-1); gr->CutMax = mglPoint(1,0,1.1);
gr->Box();
gr->Surf3(-1,a);
gr->ContF3(a,'x',-1); gr->ContF3(a,'y',-1);
gr->ContF3(a,'z', 0); gr->ContF3(a,'z',39);

MGL code

new a 61 51 40
modify a '-2*((2*x-1)^2 + (2*y-1)^2 + (2*z-1)^4 - (2*z-1)^2 - 0.1)'
rotate 40 60
light on
cut 0 -1 -1 1 0 1.1
box
surf3 a -1
contf3 a 'x' -1
contf3 a 'y' -1
contf3 a 'z' 0
contf3 a 'z' 39

Pure C code

HMDT a = mgl_create_data_size(61,51,40);
mgl_data_modify(a,"-2*((2*x-1)^2 + (2*y-1)^2 + (2*z-1)^4 - (2*z-1)^2 - 0.1)",0);
mgl_rotate(gr,40.,60.,0.);
mgl_set_light(gr,1);
mgl_set_cut_box(gr,0.,-1.,-1.,1.,0.,1.1);
mgl_box(gr,1);
mgl_surf3_val(gr,-1.,a,0);
mgl_contf3(gr,a,'x',-1, "", 7);
mgl_contf3(gr,a,'y',-1, "", 7);
mgl_contf3(gr,a,'z', 0, "", 7);
mgl_contf3(gr,a,'z',39, "", 7);
mgl_delete_data(a);

Fortran code

a = mgl_create_data_size(61,51,40);
call mgl_data_modify(a,"-2*((2*x-1)^2 + (2*y-1)^2 + (2*z-1)^4 - (2*z-1)^2 - 0.1)",0);
call mgl_rotate(gr,40.,60.,0.)
call mgl_set_light(gr,1)
call mgl_set_cut_box(gr,0.,-1.,-1.,1.,0.,1.1);
call mgl_box(gr,1)
call mgl_surf3_val(gr,-1.,a,'')
call mgl_contf3(gr,a,'x',-1, '', 7);
call mgl_contf3(gr,a,'y',-1, '', 7);
call mgl_contf3(gr,a,'z', 0, '', 7);
call mgl_contf3(gr,a,'z',39, '', 7);
call mgl_delete_data(a)

Python

a = mglData(61,51,40);
a.Modify("-2*((2*x-1)^2 + (2*y-1)^2 + (2*z-1)^4 - (2*z-1)^2 - 0.1)");
gr.Rotate(40,60);   gr.Light(True);
gr.SetCutBox(0,-1,-1,1,0,1.1);    gr.Box();
gr.Surf3(-1,a);
gr.ContF3(a,"x",-1);    gr.ContF3(a,"y",-1);
gr.ContF3(a,"z",0);     gr.ContF3(a,"z",39);

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.3.11 CutOff sample

png/surf3_cutoff

C++ code

mglData a(60,50,40);
a.Modify("-2*((2*x-1)^2 + (2*y-1)^2 + (2*z-1)^4 - (2*z-1)^2 - 0.1)");
gr->Rotate(40,60);
gr->Light(true);
gr->Alpha(true);
gr->CutOff("(z>(x+0.5*y-1)^2-1) & (z>(x-0.5*y-1)^2-1)");
gr->Box();
gr->Surf3(a);

MGL code

new a 60 50 40
modify a '-2*((2*x-1)^2 + (2*y-1)^2 + (2*z-1)^4 - (2*z-1)^2 - 0.1)'
rotate 40 60
light on
alpha on
cut '(z>(x+0.5*y-1)^2-1) & (z>(x-0.5*y-1)^2-1)'
box
surf3 a

Pure C code

HMDT a = mgl_create_data_size(60,50,40);
mgl_data_modify(a,"-2*((2*x-1)^2 + (2*y-1)^2 + (2*z-1)^4 - (2*z-1)^2 - 0.1)",0);
mgl_rotate(gr,40.,60.,0.);
mgl_set_light(gr,1);
mgl_set_alpha(gr,1);
mgl_set_cutoff(gr,"(z>(x+0.5*y-1)^2-1) & (z>(x-0.5*y-1)^2-1)");
mgl_box(gr,1);
mgl_surf3(gr,a,0,3);
mgl_delete_data(a);

Fortran code

integer a, mgl_create_data_size
a = mgl_create_data_size(60,50,40);
call mgl_data_modify(a,'-2*((2*x-1)^2 + (2*y-1)^2 + (2*z-1)^4 - (2*z-1)^2 - 0.1)',0);
call mgl_rotate(gr,40.,60.,0.)
call mgl_set_light(gr,1)
call mgl_set_alpha(gr,1)
call mgl_set_cutoff(gr,'(z>(x+0.5*y-1)^2-1) & (z>(x-0.5*y-1)^2-1)')
call mgl_box(gr,1)
call mgl_surf3(gr,a,'',3)
call mgl_delete_data(a)

Python

a = mglData(61,51,40);
a.Modify("-2*((2*x-1)^2 + (2*y-1)^2 + (2*z-1)^4 - (2*z-1)^2 - 0.1)");
gr.Rotate(40,60);   gr.Light(True);    gr.Alpha(True);
gr.CutOff("(z>(x+0.5*y-1)^2-1) & (z>(x-0.5*y-1)^2-1)");
gr.Box();
gr.Surf3(a);

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.4 Dual plotting samples


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.4.1 SurfC sample

png/surfc

C++ code

mglData a(50,40), b(50,40);
a.Modify("0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))");
b.Modify("0.6*cos(2*pi*x)*cos(3*pi*y) + 0.4*cos(3*pi*(x*y))");
gr->Rotate(40,60);
gr->Light(true);
gr->Box();
gr->SurfC(a,b);

MGL code

new a 50 40
new b 50 40
modify a '0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))'
modify b '0.6*cos(2*pi*x)*cos(3*pi*y) + 0.4*cos(3*pi*(x*y))'
rotate 40 60
light on
box
surfc a b

Pure C code

HMDT a = mgl_create_data_size(50,40,1);
HMDT b = mgl_create_data_size(50,40,1);
mgl_data_modify(a,"0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))",0);
mgl_data_modify(b,"0.6*cos(2*pi*x)*cos(3*pi*y) + 0.4*cos(3*pi*(x*y))",0);
mgl_rotate(gr,40.,60.,0.);
mgl_set_light(gr,1);
mgl_box(gr,1);
mgl_surfc(gr,a,b,0);
mgl_delete_data(a); mgl_delete_data(b);

Fortran code

integer a,b, mgl_create_data_size
a = mgl_create_data_size(50,40,1);
b = mgl_create_data_size(50,40,1);
call mgl_data_modify(a,"0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))",0);
call mgl_data_modify(b,"0.6*cos(2*pi*x)*cos(3*pi*y) + 0.4*cos(3*pi*(x*y))",0);
call mgl_rotate(gr,40.,60.,0.)
call mgl_set_light(gr,1)
call mgl_box(gr,1)
call mgl_surfc(gr,a,b,'')
call mgl_delete_data(a)
call mgl_delete_data(b)

Python

a, b = mglData(50,40), mglData(50,40);
a.Modify("0.6*sin(2*pi*x)*sin(3*pi*y)+0.4*cos(3*pi*(x*y))");
b.Modify("0.6*cos(2*pi*x)*cos(3*pi*y)+0.4*cos(3*pi*(x*y))");
gr.Rotate(40,60);   gr.Light(True);
gr.Box();
gr.SurfC(a,b);

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.4.2 SurfA sample

png/surfa

C++ code

mglData a(50,40), b(50,40);
a.Modify("0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))");
b.Modify("0.6*cos(2*pi*x)*cos(3*pi*y) + 0.4*cos(3*pi*(x*y))");
gr->Rotate(40,60);
gr->Light(true);
gr->Alpha(true);
gr->Box();
gr->SurfA(a,b);

MGL code

new a 50 40
new b 50 40
modify a '0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))'
modify b '0.6*cos(2*pi*x)*cos(3*pi*y) + 0.4*cos(3*pi*(x*y))'
rotate 40 60
light on
alpha on
box
surfa a b

Pure C code

HMDT a, b;
a = mgl_create_data_size(50,40,1);
b = mgl_create_data_size(50,40,1);
mgl_data_modify(a,"0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))",0);
mgl_data_modify(b,"0.6*cos(2*pi*x)*cos(3*pi*y) + 0.4*cos(3*pi*(x*y))",0);
mgl_rotate(gr,40.,60.,0.);
mgl_set_light(gr,1);
mgl_set_alpha(gr,1);
mgl_box(gr,1);
mgl_surfa(gr,a,b,0);
mgl_delete_data(a); mgl_delete_data(b);

Fortran code

integer a,b, mgl_create_data_size
a = mgl_create_data_size(50,40,1);
b = mgl_create_data_size(50,40,1);
call mgl_data_modify(a,"0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))",0);
call mgl_data_modify(b,"0.6*cos(2*pi*x)*cos(3*pi*y) + 0.4*cos(3*pi*(x*y))",0);
call mgl_rotate(gr,40.,60.,0.)
call mgl_set_light(gr,1)
call mgl_set_alpha(gr,1);
call mgl_box(gr,1)
call mgl_surfa(gr,a,b,'')
call mgl_delete_data(a)
call mgl_delete_data(b)

Python

a, b = mglData(50,40), mglData(50,40);
a.Modify("0.6*sin(2*pi*x)*sin(3*pi*y)+0.4*cos(3*pi*(x*y))");
b.Modify("0.6*cos(2*pi*x)*cos(3*pi*y)+0.4*cos(3*pi*(x*y))");
gr.Rotate(40,60);   gr.Light(True);    gr.Alpha(True);
gr.Box();
gr.SurfC(a,b);

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.4.3 TileS sample

png/tiles

C++ code

mglData a(50,40), b(50,40);
a.Modify("0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))");
b.Modify("0.6*cos(2*pi*x)*cos(3*pi*y) + 0.4*cos(3*pi*(x*y))");
gr->Box();
gr->TileS(a,b);

MGL code

new a 50 40
new b 50 40
modify a '0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))'
modify b '0.6*cos(2*pi*x)*cos(3*pi*y) + 0.4*cos(3*pi*(x*y))'
box
tile a b

Pure C code

HMDT a, b;
a = mgl_create_data_size(50,40,1);
b = mgl_create_data_size(50,40,1);
mgl_data_modify(a,"0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))",0);
mgl_data_modify(b,"0.6*cos(2*pi*x)*cos(3*pi*y) + 0.4*cos(3*pi*(x*y))",0);
mgl_box(gr,1);
mgl_tiles(gr,a,b,0);
mgl_delete_data(a); mgl_delete_data(b);

Fortran code

integer a,b, mgl_create_data_size
a = mgl_create_data_size(50,40,1);
b = mgl_create_data_size(50,40,1);
call mgl_data_modify(a,"0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))",0);
call mgl_data_modify(b,"0.6*cos(2*pi*x)*cos(3*pi*y) + 0.4*cos(3*pi*(x*y))",0);
call mgl_box(gr,1)
call mgl_tiles(gr,a,b,'')
call mgl_delete_data(a)
call mgl_delete_data(b)

Python

a, b = mglData(50,40), mglData(50,40);
a.Modify("0.6*sin(2*pi*x)*sin(3*pi*y)+0.4*cos(3*pi*(x*y))");
b.Modify("0.6*cos(2*pi*x)*cos(3*pi*y)+0.4*cos(3*pi*(x*y))");
gr.Box();
gr.TileS(a,b);

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.4.4 Map sample

png/map

C++ code

mglData a(50, 40), b(50, 40);
gr->Puts(mglPoint(0, 0), "\\to", "", -1.4);
gr->Axis(mglPoint(-1,-1,-2),mglPoint(1,1,2));
gr->SubPlot(2, 1, 0);
a.Fill("x", gr->Min, gr->Max);	b.Fill("y", gr->Min, gr->Max);
gr->Puts(mglPoint(0, 1.1), "\\{x, y\\}", "C", -2);		gr->Box();
gr->Map(a, b, "brgk", 0, false);
gr->SubPlot(2, 1, 1);
a.Fill("(x^3+y^3)/2", gr->Min, gr->Max);
b.Fill("(x-y)/2", gr->Min, gr->Max);
gr->Puts(mglPoint(0, 1.1), "\\{\\frac{x^3+y^3}{2}, \\frac{x-y}{2}\\}", "C", -2);
gr->Box();
gr->Map(a, b, "brgk", 0, false);

MGL code

new a 50 40
new b 50 40
text 0 0 '\to'
zrange -2 2
subplot 2 1 0
text 0 1.1 '\{x, y\}' '' -2
box
fill a 'x'
fill b 'y'
map a b 'brgk' 0 0
subplot 2 1 1
text 0 1.1 '\{\frac{x^3+y^3}{2}, \frac{x-y}{2}\}' '' -2
box
fill a '(x^3+y^3)/2'
fill b '(x-y)/2'
map a b 'brgk' 0 0

Pure C code

HMDT a = mgl_create_data_size(50,40,1);
HMDT b = mgl_create_data_size(50,40,1);
mgl_puts_ext(gr, 0.,0.,0., "\\to", "", -1.4, 't');
mgl_set_axis_3d(gr,-1.,-1.,-2.,1.,1.,2.);
mgl_subplot(gr, 2, 1, 0);
mgl_data_fill_eq(gr, a, "x", 0, 0);
mgl_data_fill_eq(gr, b, "y", 0, 0);
mgl_puts_ext(gr, 0.,1.1,0., "\\{x, y\\}", "C", -2., 't');
mgl_box(gr,1);
mgl_map(gr, a, b, "brgk", 0, 0);
mgl_subplot(gr, 2, 1, 1);
mgl_data_fill_eq(gr, a, "(x^3+y^3)/2", 0, 0);
mgl_data_fill_eq(gr, b, "(x-y)/2", 0, 0);
mgl_puts_ext(gr, 0.,1.1,0., "\\{\\frac{x^3+y^3}{2}, \\frac{x-y}{2}\\}", "C", -2., 't');
mgl_box(gr,1);
mgl_map(gr, a, b, "brgk", 0, 0);
mgl_box(gr,1);
mgl_map(gr,a,b,0,0,1);
mgl_delete_data(a); mgl_delete_data(b);

Fortran code

integer a,b, mgl_create_data_size
a = mgl_create_data_size(50,40,1);
b = mgl_create_data_size(50,40,1);
call mgl_puts_ext(gr, 0.,0.,0., '\to', '', -1.4, 't');
call mgl_set_axis_3d(gr,-1.,-1.,-2.,1.,1.,2.);
call mgl_subplot(gr, 2, 1, 0);
call mgl_data_fill_eq(gr, a, 'x', 0, 0);
call mgl_data_fill_eq(gr, b, 'y', 0, 0);
call mgl_puts_ext(gr, 0.,1.1,0., '\{x, y\}', 'C', -2., 't');
call mgl_box(gr,1);
call mgl_map(gr, a, b, 'brgk', 0, 0);
call mgl_subplot(gr, 2, 1, 1);
call mgl_data_fill_eq(gr, a, '(x^3+y^3)/2', 0, 0);
call mgl_data_fill_eq(gr, b, '(x-y)/2', 0, 0);
call mgl_puts_ext(gr, 0.,1.1,0., '\{\frac{x^3+y^3}{2}, \frac{x-y}{2}\}', 'C', -2., 't');
call mgl_box(gr,1);
call mgl_map(gr, a, b, 'brgk', 0, 0);
call mgl_box(gr,1);
call mgl_map(gr,a,b,0,0,1);
call mgl_delete_data(a)
call mgl_delete_data(b)

Python

a, b = mglData(50,40), mglData(50,40);
gr.Puts(0, 0, 0, "\\to", "", -1.4);
gr.SetRanges(-1,1,-1,1,-2,2);
gr.SubPlot(2, 1, 0);
gr.Fill(a, "x");    gr.Fill(b, "y");
gr.Puts(0, 1.1, 0, "\\{x, y\\}", "C", -2);
gr.Box();
gr.Map(a, b, "brgk", 0, 0);
gr.SubPlot(2, 1, 1);
gr.Fill(a, "(x^3+y^3)/2");   gr.Fill(b, "(x-y)/2");
gr.Puts(0, 1.1, 0, "\\{\\frac{x^3+y^3}{2}, \\frac{x-y}{2}\\}", "C", -2);
gr.Box();
gr.Map(a, b, "brgk", 0, 0);

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.4.5 Traj sample

png/traj

C++ code

mglData y(50,3), x(50), y1(50), y2(50);
y.Modify("0.7*sin(2*pi*x) + 0.5*cos(3*pi*x) + 0.2*sin(pi*x)",0);
y.Modify("sin(2*pi*x)",1);
y.Modify("cos(2*pi*x)",2);
y1.Modify("0.5+0.3*cos(2*pi*x)");
y2.Modify("0.3*sin(2*pi*x)");
x.Fill(-1,1,'x');
gr->Box();
gr->Plot(x,y);
gr->Traj(x,y,y1,y2);

MGL code

new y 50 3
new x 50
new y1 50
new y2 50
modify y '0.7*sin(2*pi*x) + 0.5*cos(3*pi*x) + 0.2*sin(pi*x)'
modify y 'sin(2*pi*x)' 1
modify y 'cos(2*pi*x)' 2
fill x -1 1
modify y1 '0.5+0.3*cos(2*pi*x)'
modify y2 '0.3*sin(2*pi*x)'
box
plot x y
traj x y y1 y2

Pure C code

HMDT y = mgl_create_data_size(50,3,1);
HMDT x= mgl_create_data_size(50,1,1);
HMDT y1 = mgl_create_data_size(50,1,1);
HMDT y2 = mgl_create_data_size(50,1,1);
mgl_data_modify(y,"0.7*sin(2*pi*x) + 0.5*cos(3*pi*x) + 0.2*sin(pi*x)",0);
mgl_data_modify(y,"sin(2*pi*x)",1);
mgl_data_modify(y,"cos(2*pi*x)",2);
mgl_data_modify(x,"2*x-1",0);
mgl_data_modify(y1,"0.5+0.3*cos(2*pi*x)",0);
mgl_data_modify(y2,"0.3*sin(2*pi*x)",0);
mgl_box(gr,1);
mgl_plot_xy(gr,x,y,NULL);
mgl_traj_xy(gr,yx,y,y1,y2,NULL,0,0);
mgl_delete_data(y);  mgl_delete_data(y1);
mgl_delete_data(x);  mgl_delete_data(y2);

Fortran code

integer x,y,y1,y2, mgl_create_data_size
y = mgl_create_data_size(50,3,1)
x= mgl_create_data_size(50,1,1);
y1 = mgl_create_data_size(50,1,1);
y2 = mgl_create_data_size(50,1,1);
call mgl_data_modify(y,'0.7*sin(2*pi*x) + 0.5*cos(3*pi*x) + 0.2*sin(pi*x)',0)
call mgl_data_modify(y,'sin(2*pi*x)',1)
call mgl_data_modify(y,'cos(2*pi*x)',2)
call mgl_data_modify(x,'2*x-1',0);
call mgl_data_modify(y1,'0.5+0.3*cos(2*pi*x)',0);
call mgl_data_modify(y2,'0.3*sin(2*pi*x)',0);
call mgl_box(gr,1)
call mgl_plot_xy(gr,x,y,NULL);
call mgl_traj_xy(gr,yx,y,y1,y2,NULL,0,0);
call mgl_delete_data(y)
call mgl_delete_data(x)
call mgl_delete_data(y1)
call mgl_delete_data(y2)

Python

x,y,y1,y2 = mglData(50), mglData(50,3), mglData(50), mglData(50);
y.Modify("0.7*sin(2*pi*x)+0.5*cos(3*pi*x)+0.2*sin(pi*x)",0);
y.Modify("sin(2*pi*x)",1);
y.Modify("cos(2*pi*x)",2);
y1.Modify("0.5+0.3*cos(2*pi*x)");
y2.Modify("0.3*sin(2*pi*x)");
x.Fill(-1,1,'x');
gr.Box();
gr.Plot(x,y);
gr.Traj(x,y,y1,y2);

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.4.6 Vect sample

png/vect

C++ code

mglData a(20,30), b(20,30);
a.Modify("0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))");
b.Modify("0.6*cos(2*pi*x)*cos(3*pi*y) + 0.4*cos(3*pi*(x*y))");
gr->Box();
gr->Vect(a,b);

MGL code

new a 20 30
new b 20 30
modify a '0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))'
modify b '0.6*cos(2*pi*x)*cos(3*pi*y) + 0.4*cos(3*pi*(x*y))'
box
vect a b

Pure C code

HMDT a = mgl_create_data_size(20,30,1);
HMDT b = mgl_create_data_size(20,30,1);
mgl_data_modify(a,"0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))",0);
mgl_data_modify(b,"0.6*cos(2*pi*x)*cos(3*pi*y) + 0.4*cos(3*pi*(x*y))",0);
mgl_box(gr,1);
mgl_vect_2d(gr,a,b,0,0.);
mgl_delete_data(a); mgl_delete_data(b);

Fortran code

integer a,b, mgl_create_data_size
a = mgl_create_data_size(20,30,1);
b = mgl_create_data_size(20,30,1);
call mgl_data_modify(a,"0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))",0);
call mgl_data_modify(b,"0.6*cos(2*pi*x)*cos(3*pi*y) + 0.4*cos(3*pi*(x*y))",0);
call mgl_box(gr,1)
call mgl_vect_2d(gr,a,b,'',0.)
call mgl_delete_data(a)
call mgl_delete_data(b)

Python

a, b = mglData(20,30), mglData(20,30);
a.Modify("0.6*sin(2*pi*x)*sin(3*pi*y)+0.4*cos(3*pi*(x*y))");
b.Modify("0.6*cos(2*pi*x)*cos(3*pi*y)+0.4*cos(3*pi*(x*y))");
gr.Box();
gr.Vect(a,b);

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.4.7 VectL sample

png/vectl

C++ code

mglData a(20,30), b(20,30);
a.Modify("0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))");
b.Modify("0.6*cos(2*pi*x)*cos(3*pi*y) + 0.4*cos(3*pi*(x*y))");
gr->Box();
gr->VectL(a,b);

MGL code

new a 20 30
new b 20 30
modify a '0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))'
modify b '0.6*cos(2*pi*x)*cos(3*pi*y) + 0.4*cos(3*pi*(x*y))'
box
vectl a b

Pure C code

HMDT a, b;
a = mgl_create_data_size(20,30,1);
b = mgl_create_data_size(20,30,1);
mgl_data_modify(a,"0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))",0);
mgl_data_modify(b,"0.6*cos(2*pi*x)*cos(3*pi*y) + 0.4*cos(3*pi*(x*y))",0);
mgl_box(gr,1);
mgl_vectl_2d(gr,a,b,0,0.);
mgl_delete_data(a); mgl_delete_data(b);

Fortran code

integer a,b, mgl_create_data_size
a = mgl_create_data_size(20,30,1);
b = mgl_create_data_size(20,30,1);
call mgl_data_modify(a,"0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))",0);
call mgl_data_modify(b,"0.6*cos(2*pi*x)*cos(3*pi*y) + 0.4*cos(3*pi*(x*y))",0);
call mgl_box(gr,1)
call mgl_vectl_2d(gr,a,b,'',0.)
call mgl_delete_data(a)
call mgl_delete_data(b)

Python

a, b = mglData(20,30), mglData(20,30);
a.Modify("0.6*sin(2*pi*x)*sin(3*pi*y)+0.4*cos(3*pi*(x*y))");
b.Modify("0.6*cos(2*pi*x)*cos(3*pi*y)+0.4*cos(3*pi*(x*y))");
gr.Box();
gr.VectL(a,b);

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.4.8 VectC sample

png/vectc

C++ code

mglData a(20,30), b(20,30);
a.Modify("0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))");
b.Modify("0.6*cos(2*pi*x)*cos(3*pi*y) + 0.4*cos(3*pi*(x*y))");
gr->Box();
gr->VectC(a,b);

MGL code

new a 20 30
new b 20 30
modify a '0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))'
modify b '0.6*cos(2*pi*x)*cos(3*pi*y) + 0.4*cos(3*pi*(x*y))'
box
vectc a b

Pure C code

HMDT a, b;
a = mgl_create_data_size(20,30,1);
b = mgl_create_data_size(20,30,1);
mgl_data_modify(a,"0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))",0);
mgl_data_modify(b,"0.6*cos(2*pi*x)*cos(3*pi*y) + 0.4*cos(3*pi*(x*y))",0);
mgl_box(gr,1);
mgl_vectc_2d(gr,a,b,0,0.);
mgl_delete_data(a); mgl_delete_data(b);

Fortran code

integer a,b, mgl_create_data_size
a = mgl_create_data_size(20,30,1);
b = mgl_create_data_size(20,30,1);
call mgl_data_modify(a,"0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))",0);
call mgl_data_modify(b,"0.6*cos(2*pi*x)*cos(3*pi*y) + 0.4*cos(3*pi*(x*y))",0);
call mgl_box(gr,1)
call mgl_vectc_2d(gr,a,b,'',0.)
call mgl_delete_data(a)
call mgl_delete_data(b)

Python

a, b = mglData(20,30), mglData(20,30);
a.Modify("0.6*sin(2*pi*x)*sin(3*pi*y)+0.4*cos(3*pi*(x*y))");
b.Modify("0.6*cos(2*pi*x)*cos(3*pi*y)+0.4*cos(3*pi*(x*y))");
gr.Box();
gr.VectC(a,b);

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.4.9 Flow sample

png/flow

C++ code

mglData a(20,30), b(20,30);
a.Modify("0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))");
b.Modify("0.6*cos(2*pi*x)*cos(3*pi*y) + 0.4*cos(3*pi*(x*y))");
gr->Box();
gr->Flow(a,b);

MGL code

new a 20 30
new b 20 30
modify a '0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))'
modify b '0.6*cos(2*pi*x)*cos(3*pi*y) + 0.4*cos(3*pi*(x*y))'
box
flow a b

Pure C code

HMDT a = mgl_create_data_size(20,30,1);
HMDT b = mgl_create_data_size(20,30,1);
mgl_data_modify(a,"0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))",0);
mgl_data_modify(b,"0.6*cos(2*pi*x)*cos(3*pi*y) + 0.4*cos(3*pi*(x*y))",0);
mgl_box(gr,1);
mgl_flow_2d(gr,a,b,0,5,1,0.);
mgl_delete_data(a); mgl_delete_data(b);

Fortran code

integer a,b, mgl_create_data_size
a = mgl_create_data_size(20,30,1);
b = mgl_create_data_size(20,30,1);
call mgl_data_modify(a,"0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))",0);
call mgl_data_modify(b,"0.6*cos(2*pi*x)*cos(3*pi*y) + 0.4*cos(3*pi*(x*y))",0);
call mgl_box(gr,1)
call mgl_flow_2d(gr,a,b,'',5,1,0.)
call mgl_delete_data(a)
call mgl_delete_data(b)

Python

a, b = mglData(20,30), mglData(20,30);
a.Modify("0.6*sin(2*pi*x)*sin(3*pi*y)+0.4*cos(3*pi*(x*y))");
b.Modify("0.6*cos(2*pi*x)*cos(3*pi*y)+0.4*cos(3*pi*(x*y))");
gr.Box();
gr.Flow(a,b);

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.4.10 Pipe sample

png/pipe

C++ code

mglData a(20,30), b(20,30);
a.Modify("0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))");
b.Modify("0.6*cos(2*pi*x)*cos(3*pi*y) + 0.4*cos(3*pi*(x*y))");
gr->Light(true);
gr->Box();
gr->Pipe(a,b);

MGL code

new a 20 30
new b 20 30
modify a '0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))'
modify b '0.6*cos(2*pi*x)*cos(3*pi*y) + 0.4*cos(3*pi*(x*y))'
light on
box
pipe a b

Pure C code

HMDT a = mgl_create_data_size(20,30,1);
HMDT b = mgl_create_data_size(20,30,1);
mgl_data_modify(a,"0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))",0);
mgl_data_modify(b,"0.6*cos(2*pi*x)*cos(3*pi*y) + 0.4*cos(3*pi*(x*y))",0);
mgl_set_light(gr,1);
mgl_box(gr,1);
mgl_pipe_2d(gr,a,b,0,0.05,5,1,0.);
mgl_delete_data(a); mgl_delete_data(b);

Fortran code

integer a,b, mgl_create_data_size
a = mgl_create_data_size(20,30,1);
b = mgl_create_data_size(20,30,1);
call mgl_data_modify(a,"0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))",0);
call mgl_data_modify(b,"0.6*cos(2*pi*x)*cos(3*pi*y) + 0.4*cos(3*pi*(x*y))",0);
call mgl_set_light(gr,1)
call mgl_box(gr,1)
call mgl_pipe_2d(gr,a,b,'',0.05,5,1,0.)
call mgl_delete_data(a)
call mgl_delete_data(b)

Python

a, b = mglData(20,30), mglData(20,30);
a.Modify("0.6*sin(2*pi*x)*sin(3*pi*y)+0.4*cos(3*pi*(x*y))");
b.Modify("0.6*cos(2*pi*x)*cos(3*pi*y)+0.4*cos(3*pi*(x*y))");
gr.Light(True);    gr.Box();
gr.Pipe(a,b);

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.4.11 Dew sample

png/dew

C++ code

mglData a(20,30), b(20,30);
a.Modify("0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))");
b.Modify("0.6*cos(2*pi*x)*cos(3*pi*y) + 0.4*cos(3*pi*(x*y))");
gr->Box();
gr->Light(true);
gr->Dew(a,b);

MGL code

new a 20 30
new b 20 30
modify a '0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))'
modify b '0.6*cos(2*pi*x)*cos(3*pi*y) + 0.4*cos(3*pi*(x*y))'
box
light on
dew a b

Pure C code

HMDT a = mgl_create_data_size(20,30,1);
HMDT b = mgl_create_data_size(20,30,1);
mgl_data_modify(a,"0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))",0);
mgl_data_modify(b,"0.6*cos(2*pi*x)*cos(3*pi*y) + 0.4*cos(3*pi*(x*y))",0);
mgl_box(gr,1);
mgl_set_light(gr,1);
mgl_dew_2d(gr,a,b,0,0.);
mgl_delete_data(a); mgl_delete_data(b);

Fortran code

integer a,b, mgl_create_data_size
a = mgl_create_data_size(20,30,1);
b = mgl_create_data_size(20,30,1);
call mgl_data_modify(a,"0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))",0);
call mgl_data_modify(b,"0.6*cos(2*pi*x)*cos(3*pi*y) + 0.4*cos(3*pi*(x*y))",0);
call mgl_box(gr,1)
call mgl_set_light(gr,1);
call mgl_dew_2d(gr,a,b,'',0.)
call mgl_delete_data(a)
call mgl_delete_data(b)

Python

a, b = mglData(20,30), mglData(20,30);
a.Modify("0.6*sin(2*pi*x)*sin(3*pi*y)+0.4*cos(3*pi*(x*y))");
b.Modify("0.6*cos(2*pi*x)*cos(3*pi*y)+0.4*cos(3*pi*(x*y))");
gr.Light(True);    gr.Box();
gr.Dew(a,b);

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.4.12 Surf3C sample

png/surf3c

C++ code

mglData a(60,50,40), b(60,50,40);
a.Modify("-2*((2*x-1)^2 + (2*y-1)^2 + (2*z-1)^4 - (2*z-1)^2 - 0.1)");
b.Modify("1-2*tanh(4*(x+y-1)^2)");
gr->Rotate(40,60);
gr->Light(true);
gr->Alpha(true);
gr->Box();
gr->Surf3C(a, b);

MGL code

new a 60 50 40
new b 60 50 40
modify a '-2*((2*x-1)^2 + (2*y-1)^2 + (2*z-1)^4 - (2*z-1)^2 - 0.1)'
modify b '1-2*tanh(4*(x+y-1)^2)'
rotate 40 60
light on
alpha on
box
surf3c a b

Pure C code

HMDT a = mgl_create_data_size(60,50,40);
HMDT b = mgl_create_data_size(60,50,40);
mgl_data_modify(a,"-2*((2*x-1)^2 + (2*y-1)^2 + (2*z-1)^4 - (2*z-1)^2 - 0.1)",0);
mgl_data_modify(b,"1-2*tanh(4*(x+y-1)^2)",0);
mgl_rotate(gr,40.,60.,0.);
mgl_set_light(gr,1);
mgl_set_alpha(gr,1);
mgl_box(gr,1);
mgl_surf3c(gr,a,b,0,3);
mgl_delete_data(a); mgl_delete_data(b);

Fortran code

integer a,b, mgl_create_data_size
a = mgl_create_data_size(60,50,40);
b = mgl_create_data_size(60,50,40);
call mgl_data_modify(a,"-2*((2*x-1)^2 + (2*y-1)^2 + (2*z-1)^4 - (2*z-1)^2 - 0.1)",0);
call mgl_data_modify(b,"1-2*tanh(4*(x+y-1)^2)",0);
call mgl_rotate(gr,40.,60.,0.)
call mgl_set_light(gr,1)
call mgl_set_alpha(gr,1)
call mgl_box(gr,1)
call mgl_surf3c(gr,a,b,'',3)
call mgl_delete_data(a)
call mgl_delete_data(b)

Python

a, b = mglData(60,50,40), mglData(60,50,40);
a.Modify("-2*((2*x-1)^2+(2*y-1)^2+(2*z-1)^4-(2*z-1)^2-0.1)");
b.Modify("1-2*tanh(4*(x+y-1)^2)");
gr.Rotate(40,60);   gr.Light(True);     gr.Alpha(True);
gr.Box();
gr.Surf3C(a,b);

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.4.13 Surf3A sample

png/surf3a

C++ code

mglData a(60,50,40), b(60,50,40);
a.Modify("-2*((2*x-1)^2 + (2*y-1)^2 + (2*z-1)^4 - (2*z-1)^2 - 0.1)");
b.Modify("1-2*tanh(4*(x+y-1)^2)");
gr->Rotate(40,60);
gr->Light(true);
gr->Alpha(true);
gr->Box();
gr->Surf3A(a, b);

MGL code

new a 60 50 40
new b 60 50 40
modify a '-2*((2*x-1)^2 + (2*y-1)^2 + (2*z-1)^4 - (2*z-1)^2 - 0.1)'
modify b '1-2*tanh(4*(x+y-1)^2)'
rotate 40 60
light on
alpha on
box
surf3a a b

Pure C code

HMDT a, b; a = mgl_create_data_size(60,50,40);
b = mgl_create_data_size(60,50,40);
mgl_data_modify(a,"-2*((2*x-1)^2 + (2*y-1)^2 + (2*z-1)^4 - (2*z-1)^2 - 0.1)",0);
mgl_data_modify(b,"1-2*tanh(4*(x+y-1)^2)",0);
mgl_rotate(gr,40.,60.,0.);
mgl_set_light(gr,1);
mgl_set_alpha(gr,1);
mgl_box(gr,1);
mgl_surf3a(gr,a,b,0,3);
mgl_delete_data(a); mgl_delete_data(b);

Fortran code

integer a,b, mgl_create_data_size
a = mgl_create_data_size(60,50,40);
b = mgl_create_data_size(60,50,40);
call mgl_data_modify(a,"-2*((2*x-1)^2 + (2*y-1)^2 + (2*z-1)^4 - (2*z-1)^2 - 0.1)",0);
call mgl_data_modify(b,"1-2*tanh(4*(x+y-1)^2)",0);
call mgl_rotate(gr,40.,60.,0.)
call mgl_set_light(gr,1)
call mgl_set_alpha(gr,1)
call mgl_box(gr,1)
call mgl_surf3a(gr,a,b,'',3)
call mgl_delete_data(a)
call mgl_delete_data(b)

Python

a, b = mglData(60,50,40), mglData(60,50,40);
a.Modify("-2*((2*x-1)^2+(2*y-1)^2+(2*z-1)^4-(2*z-1)^2-0.1)");
b.Modify("1-2*tanh(4*(x+y-1)^2)");
gr.Rotate(40,60);   gr.Light(True);     gr.Alpha(True);
gr.Box();
gr.Surf3A(a,b);

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.4.14 Vect 3D sample

png/vect3

C++ code

mglData ex(10,10,10), ey(10,10,10), ez(10,10,10);
ex.Fill("0.2*x/pow(x^2+y^2+(z-0.3)^2,1.5) - \
        0.2*x/pow(x^2+y^2+(z+0.3)^2,1.5)", gr->Min, gr->Max);
ey.Fill("0.2*y/pow(x^2+y^2+(z-0.3)^2,1.5) - \
         0.2*y/pow(x^2+y^2+(z+0.3)^2,1.5)", gr->Min, gr->Max);
ez.Fill("0.2*(z-0.3)/pow(x^2+y^2+(z-0.3)^2,1.5) - \
         0.2*(z+0.3)/pow(x^2+y^2+(z+0.3)^2,1.5)", gr->Min, gr->Max);
gr->Rotate(40,60);
gr->Box();
gr->Vect(ex, ey, ez, "bwr");

MGL code

new ex 10 10 10
new ey 10 10 10
new ez 10 10 10
fill ex '0.2*x/pow(x^2+y^2+(z-0.3)^2,1.5) - 0.2*x/pow(x^2+y^2+(z+0.3)^2,1.5)'
fill ey '0.2*y/pow(x^2+y^2+(z-0.3)^2,1.5) - 0.2*y/pow(x^2+y^2+(z+0.3)^2,1.5)'
fill ez '0.2*(z-0.3)/pow(x^2+y^2+(z-0.3)^2,1.5) - 0.2*(z+0.3)/pow(x^2+y^2+(z+0.3)^2,1.5)'
rotate 40 60
box
vect ex ey ez 'bwr'

Pure C code

HMDT ex, ey, ez;
ex = mgl_create_data_size(10,10,10);
ey = mgl_create_data_size(10,10,10);
ez = mgl_create_data_size(10,10,10);
mgl_data_fill_eq(gr, ex, "0.2*x/pow(x^2+y^2+(z-0.3)^2,1.5) - \
        0.2*x/pow(x^2+y^2+(z+0.3)^2,1.5)",0,0);
mgl_data_fill_eq(gr, ey, "0.2*y/pow(x^2+y^2+(z-0.3)^2,1.5) - \
         0.2*y/pow(x^2+y^2+(z+0.3)^2,1.5)",0,0);
mgl_data_fill_eq(gr, ez, "0.2*(z-0.3)/pow(x^2+y^2+(z-0.3)^2,1.5) - \
         0.2*(z+0.3)/pow(x^2+y^2+(z+0.3)^2,1.5)",0,0);
mgl_rotate(gr,40.,60.,0.);
mgl_box(gr,1);
mgl_vect_3d(gr,ex,ey,ez,"bwr");
mgl_delete_data(ex); mgl_delete_data(ey); mgl_delete_data(ez);

Fortran code

integer ex,ey,ez, mgl_create_data_size
ex = mgl_create_data_size(10,10,10)
ey = mgl_create_data_size(10,10,10)
ez = mgl_create_data_size(10,10,10)
call mgl_data_fill_eq(gr, ex, '0.2*x/pow(x^2+y^2+(z-0.3)^2,1.5) - &
        0.2*x/pow(x^2+y^2+(z+0.3)^2,1.5)',0,0);
call mgl_data_fill_eq(gr, ey, '0.2*y/pow(x^2+y^2+(z-0.3)^2,1.5) - &
         0.2*y/pow(x^2+y^2+(z+0.3)^2,1.5)',0,0);
call mgl_data_fill_eq(gr, ez, '0.2*(z-0.3)/pow(x^2+y^2+(z-0.3)^2,1.5) - &
         0.2*(z+0.3)/pow(x^2+y^2+(z+0.3)^2,1.5)',0,0);
call mgl_rotate(gr,40.,60.,0.)
call mgl_box(gr,1);
call mgl_vect_3d(gr,ex,ey,ez,'bwr')
call mgl_delete_data(ex)
call mgl_delete_data(ey)
call mgl_delete_data(ez)

Python

ex, ey, ez = mglData(10,10,10), mglData(10,10,10), mglData(10,10,10);
gr.Fill(ex, "0.2*x/pow(x^2+y^2+(z-0.3)^2,1.5) - \
        0.2*x/pow(x^2+y^2+(z+0.3)^2,1.5)");
gr.Fill(ey, "0.2*y/pow(x^2+y^2+(z-0.3)^2,1.5) - \
         0.2*y/pow(x^2+y^2+(z+0.3)^2,1.5)");
gr.Fill(ez, "0.2*(z-0.3)/pow(x^2+y^2+(z-0.3)^2,1.5) - \
         0.2*(z+0.3)/pow(x^2+y^2+(z+0.3)^2,1.5)");
gr.Rotate(40,60);       gr.Box();
gr.Vect(ex,ey,ez,"bwr");

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.4.15 VectL 3D sample

png/vectl3

C++ code

mglData ex(10,10,10), ey(10,10,10), ez(10,10,10);
ex.Fill("0.2*x/pow(x^2+y^2+(z-0.3)^2,1.5) - \
        0.2*x/pow(x^2+y^2+(z+0.3)^2,1.5)", gr->Min, gr->Max);
ey.Fill("0.2*y/pow(x^2+y^2+(z-0.3)^2,1.5) - \
         0.2*y/pow(x^2+y^2+(z+0.3)^2,1.5)", gr->Min, gr->Max);
ez.Fill("0.2*(z-0.3)/pow(x^2+y^2+(z-0.3)^2,1.5) - \
         0.2*(z+0.3)/pow(x^2+y^2+(z+0.3)^2,1.5)", gr->Min, gr->Max);
gr->Rotate(40,60);
gr->Box();
gr->VectL(ex, ey, ez, "bwr");

MGL code

new ex 10 10 10
new ey 10 10 10
new ez 10 10 10
fill ex '0.2*x/pow(x^2+y^2+(z-0.3)^2,1.5) - 0.2*x/pow(x^2+y^2+(z+0.3)^2,1.5)'
fill ey '0.2*y/pow(x^2+y^2+(z-0.3)^2,1.5) - 0.2*y/pow(x^2+y^2+(z+0.3)^2,1.5)'
fill ez '0.2*(z-0.3)/pow(x^2+y^2+(z-0.3)^2,1.5) - 0.2*(z+0.3)/pow(x^2+y^2+(z+0.3)^2,1.5)'
rotate 40 60
box
vectl ex ey ez 'bwr'

Pure C code

HMDT ex, ey, ez;
ex = mgl_create_data_size(10,10,10);
ey = mgl_create_data_size(10,10,10);
ez = mgl_create_data_size(10,10,10);
mgl_data_fill_eq(gr, ex, "0.2*x/pow(x^2+y^2+(z-0.3)^2,1.5) - \
        0.2*x/pow(x^2+y^2+(z+0.3)^2,1.5)",0,0);
mgl_data_fill_eq(gr, ey, "0.2*y/pow(x^2+y^2+(z-0.3)^2,1.5) - \
         0.2*y/pow(x^2+y^2+(z+0.3)^2,1.5)",0,0);
mgl_data_fill_eq(gr, ez, "0.2*(z-0.3)/pow(x^2+y^2+(z-0.3)^2,1.5) - \
         0.2*(z+0.3)/pow(x^2+y^2+(z+0.3)^2,1.5)",0,0);
mgl_rotate(gr,40.,60.,0.);
mgl_box(gr,1);
mgl_vectl_3d(gr,ex,ey,ez,"bwr");
mgl_delete_data(ex); mgl_delete_data(ey); mgl_delete_data(ez);

Fortran code

integer ex,ey,ez, mgl_create_data_size
ex = mgl_create_data_size(10,10,10)
ey = mgl_create_data_size(10,10,10)
ez = mgl_create_data_size(10,10,10)
call mgl_data_fill_eq(gr, ex, '0.2*x/pow(x^2+y^2+(z-0.3)^2,1.5) - &
        0.2*x/pow(x^2+y^2+(z+0.3)^2,1.5)',0,0);
call mgl_data_fill_eq(gr, ey, '0.2*y/pow(x^2+y^2+(z-0.3)^2,1.5) - &
         0.2*y/pow(x^2+y^2+(z+0.3)^2,1.5)',0,0);
call mgl_data_fill_eq(gr, ez, '0.2*(z-0.3)/pow(x^2+y^2+(z-0.3)^2,1.5) - &
         0.2*(z+0.3)/pow(x^2+y^2+(z+0.3)^2,1.5)',0,0);
call mgl_rotate(gr,40.,60.,0.)
call mgl_box(gr,1);
call mgl_vectl_3d(gr,ex,ey,ez,'bwr')
call mgl_delete_data(ex)
call mgl_delete_data(ey)
call mgl_delete_data(ez)

Python

ex, ey, ez = mglData(10,10,10), mglData(10,10,10), mglData(10,10,10);
gr.Fill(ex, "0.2*x/pow(x^2+y^2+(z-0.3)^2,1.5) - \
        0.2*x/pow(x^2+y^2+(z+0.3)^2,1.5)");
gr.Fill(ey, "0.2*y/pow(x^2+y^2+(z-0.3)^2,1.5) - \
         0.2*y/pow(x^2+y^2+(z+0.3)^2,1.5)");
gr.Fill(ez, "0.2*(z-0.3)/pow(x^2+y^2+(z-0.3)^2,1.5) - \
         0.2*(z+0.3)/pow(x^2+y^2+(z+0.3)^2,1.5)");
gr.Rotate(40,60);       gr.Box();
gr.VectL(ex,ey,ez,"bwr");

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.4.16 VectC 3D sample

png/vectc3

C++ code

mglData ex(10,10,10), ey(10,10,10), ez(10,10,10);
ex.Fill("0.2*x/pow(x^2+y^2+(z-0.3)^2,1.5) - \
        0.2*x/pow(x^2+y^2+(z+0.3)^2,1.5)", gr->Min, gr->Max);
ey.Fill("0.2*y/pow(x^2+y^2+(z-0.3)^2,1.5) - \
         0.2*y/pow(x^2+y^2+(z+0.3)^2,1.5)", gr->Min, gr->Max);
ez.Fill("0.2*(z-0.3)/pow(x^2+y^2+(z-0.3)^2,1.5) - \
         0.2*(z+0.3)/pow(x^2+y^2+(z+0.3)^2,1.5)", gr->Min, gr->Max);
gr->Rotate(40,60);
gr->Box();
gr->VectC(ex, ey, ez, "bwr");

MGL code

new ex 10 10 10
new ey 10 10 10
new ez 10 10 10
fill ex '0.2*x/pow(x^2+y^2+(z-0.3)^2,1.5) - 0.2*x/pow(x^2+y^2+(z+0.3)^2,1.5)'
fill ey '0.2*y/pow(x^2+y^2+(z-0.3)^2,1.5) - 0.2*y/pow(x^2+y^2+(z+0.3)^2,1.5)'
fill ez '0.2*(z-0.3)/pow(x^2+y^2+(z-0.3)^2,1.5) - 0.2*(z+0.3)/pow(x^2+y^2+(z+0.3)^2,1.5)'
rotate 40 60
box
vectc ex ey ez 'bwr'

Pure C code

HMDT ex, ey, ez;
ex = mgl_create_data_size(10,10,10);
ey = mgl_create_data_size(10,10,10);
ez = mgl_create_data_size(10,10,10);
mgl_data_fill_eq(gr, ex, "0.2*x/pow(x^2+y^2+(z-0.3)^2,1.5) - \
        0.2*x/pow(x^2+y^2+(z+0.3)^2,1.5)",0,0);
mgl_data_fill_eq(gr, ey, "0.2*y/pow(x^2+y^2+(z-0.3)^2,1.5) - \
         0.2*y/pow(x^2+y^2+(z+0.3)^2,1.5)",0,0);
mgl_data_fill_eq(gr, ez, "0.2*(z-0.3)/pow(x^2+y^2+(z-0.3)^2,1.5) - \
         0.2*(z+0.3)/pow(x^2+y^2+(z+0.3)^2,1.5)",0,0);
mgl_rotate(gr,40.,60.,0.);
mgl_box(gr,1);
mgl_vectc_3d(gr,ex,ey,ez,"bwr");
mgl_delete_data(ex); mgl_delete_data(ey); mgl_delete_data(ez);

Fortran code

integer ex,ey,ez, mgl_create_data_size
ex = mgl_create_data_size(10,10,10)
ey = mgl_create_data_size(10,10,10)
ez = mgl_create_data_size(10,10,10)
call mgl_data_fill_eq(gr, ex, '0.2*x/pow(x^2+y^2+(z-0.3)^2,1.5) - &
        0.2*x/pow(x^2+y^2+(z+0.3)^2,1.5)',0,0);
call mgl_data_fill_eq(gr, ey, '0.2*y/pow(x^2+y^2+(z-0.3)^2,1.5) - &
         0.2*y/pow(x^2+y^2+(z+0.3)^2,1.5)',0,0);
call mgl_data_fill_eq(gr, ez, '0.2*(z-0.3)/pow(x^2+y^2+(z-0.3)^2,1.5) - &
         0.2*(z+0.3)/pow(x^2+y^2+(z+0.3)^2,1.5)',0,0);
call mgl_rotate(gr,40.,60.,0.)
call mgl_box(gr,1);
call mgl_vectc_3d(gr,ex,ey,ez,'bwr')
call mgl_delete_data(ex)
call mgl_delete_data(ey)
call mgl_delete_data(ez)

Python

ex, ey, ez = mglData(10,10,10), mglData(10,10,10), mglData(10,10,10);
gr.Fill(ex, "0.2*x/pow(x^2+y^2+(z-0.3)^2,1.5) - \
        0.2*x/pow(x^2+y^2+(z+0.3)^2,1.5)");
gr.Fill(ey, "0.2*y/pow(x^2+y^2+(z-0.3)^2,1.5) - \
         0.2*y/pow(x^2+y^2+(z+0.3)^2,1.5)");
gr.Fill(ez, "0.2*(z-0.3)/pow(x^2+y^2+(z-0.3)^2,1.5) - \
         0.2*(z+0.3)/pow(x^2+y^2+(z+0.3)^2,1.5)");
gr.Rotate(40,60);       gr.Box();
gr.VectC(ex,ey,ez,"bwr");

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.4.17 Flow 3D sample

png/flow3

C++ code

mglData ex(30,30,30), ey(30,30,30), ez(30,30,30);
ex.Fill("0.2*x/pow(x^2+y^2+(z-0.3)^2,1.5) - \
        0.2*x/pow(x^2+y^2+(z+0.3)^2,1.5)", gr->Min, gr->Max);
ey.Fill("0.2*y/pow(x^2+y^2+(z-0.3)^2,1.5) - \
         0.2*y/pow(x^2+y^2+(z+0.3)^2,1.5)", gr->Min, gr->Max);
ez.Fill("0.2*(z-0.3)/pow(x^2+y^2+(z-0.3)^2,1.5) - \
         0.2*(z+0.3)/pow(x^2+y^2+(z+0.3)^2,1.5)", gr->Min, gr->Max);
gr->Rotate(40,60);
gr->Box();
gr->Flow(ex, ey, ez, "bwr");

MGL code

new ex 30 30 30
new ey 30 30 30
new ez 30 30 30
fill ex '0.2*x/pow(x^2+y^2+(z-0.3)^2,1.5) - 0.2*x/pow(x^2+y^2+(z+0.3)^2,1.5)'
fill ey '0.2*y/pow(x^2+y^2+(z-0.3)^2,1.5) - 0.2*y/pow(x^2+y^2+(z+0.3)^2,1.5)'
fill ez '0.2*(z-0.3)/pow(x^2+y^2+(z-0.3)^2,1.5) - 0.2*(z+0.3)/pow(x^2+y^2+(z+0.3)^2,1.5)'
rotate 40 60
box
flow ex ey ez 'bwr'

Pure C code

HMDT ex, ey, ez;
ex = mgl_create_data_size(30,30,30);
ey = mgl_create_data_size(30,30,30);
ez = mgl_create_data_size(30,30,30);
mgl_data_fill_eq(gr, ex, "0.2*x/pow(x^2+y^2+(z-0.3)^2,1.5) - \
        0.2*x/pow(x^2+y^2+(z+0.3)^2,1.5)",0,0);
mgl_data_fill_eq(gr, ey, "0.2*y/pow(x^2+y^2+(z-0.3)^2,1.5) - \
         0.2*y/pow(x^2+y^2+(z+0.3)^2,1.5)",0,0);
mgl_data_fill_eq(gr, ez, "0.2*(z-0.3)/pow(x^2+y^2+(z-0.3)^2,1.5) - \
         0.2*(z+0.3)/pow(x^2+y^2+(z+0.3)^2,1.5)",0,0);
mgl_rotate(gr,40.,60.,0.);
mgl_box(gr,1);
mgl_flow_3d(gr,ex,ey,ez,"bwr",3,1);
mgl_delete_data(ex); mgl_delete_data(ey); mgl_delete_data(ez);

Fortran code

integer ex,ey,ez, mgl_create_data_size
ex = mgl_create_data_size(30,30,30)
ey = mgl_create_data_size(30,30,30)
ez = mgl_create_data_size(30,30,30)
call mgl_data_fill_eq(gr, ex, '0.2*x/pow(x^2+y^2+(z-0.3)^2,1.5) - &
        0.2*x/pow(x^2+y^2+(z+0.3)^2,1.5)',0,0);
call mgl_data_fill_eq(gr, ey, '0.2*y/pow(x^2+y^2+(z-0.3)^2,1.5) - &
         0.2*y/pow(x^2+y^2+(z+0.3)^2,1.5)',0,0);
call mgl_data_fill_eq(gr, ez, '0.2*(z-0.3)/pow(x^2+y^2+(z-0.3)^2,1.5) - &
         0.2*(z+0.3)/pow(x^2+y^2+(z+0.3)^2,1.5)',0,0);
call mgl_rotate(gr,40.,60.,0.)
call mgl_box(gr,1);
call mgl_flow_3d(gr,ex,ey,ez,'bwr',3,1)
call mgl_delete_data(ex)
call mgl_delete_data(ey)
call mgl_delete_data(ez)

Python

ex, ey, ez = mglData(10,10,10), mglData(10,10,10), mglData(10,10,10);
gr.Fill(ex, "0.2*x/pow(x^2+y^2+(z-0.3)^2,1.5) - \
        0.2*x/pow(x^2+y^2+(z+0.3)^2,1.5)");
gr.Fill(ey, "0.2*y/pow(x^2+y^2+(z-0.3)^2,1.5) - \
         0.2*y/pow(x^2+y^2+(z+0.3)^2,1.5)");
gr.Fill(ez, "0.2*(z-0.3)/pow(x^2+y^2+(z-0.3)^2,1.5) - \
         0.2*(z+0.3)/pow(x^2+y^2+(z+0.3)^2,1.5)");
gr.Rotate(40,60);       gr.Box();
gr.Flow(ex,ey,ez,"bwr");

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.4.18 Pipe 3D sample

png/pipe3

C++ code

mglData ex(10,10,10), ey(10,10,10), ez(10,10,10);
ex.Fill("0.2*x/pow(x^2+y^2+(z-0.3)^2,1.5) - \
        0.2*x/pow(x^2+y^2+(z+0.3)^2,1.5)", gr->Min, gr->Max);
ey.Fill("0.2*y/pow(x^2+y^2+(z-0.3)^2,1.5) - \
         0.2*y/pow(x^2+y^2+(z+0.3)^2,1.5)", gr->Min, gr->Max);
ez.Fill("0.2*(z-0.3)/pow(x^2+y^2+(z-0.3)^2,1.5) - \
         0.2*(z+0.3)/pow(x^2+y^2+(z+0.3)^2,1.5)", gr->Min, gr->Max);
gr->Rotate(40,60);
gr->Light(true);
gr->Box();
gr->Pipe(ex, ey, ez, "bwr");

MGL code

new ex 10 10 10
new ey 10 10 10
new ez 10 10 10
fill ex '0.2*x/pow(x^2+y^2+(z-0.3)^2,1.5) - 0.2*x/pow(x^2+y^2+(z+0.3)^2,1.5)'
fill ey '0.2*y/pow(x^2+y^2+(z-0.3)^2,1.5) - 0.2*y/pow(x^2+y^2+(z+0.3)^2,1.5)'
fill ez '0.2*(z-0.3)/pow(x^2+y^2+(z-0.3)^2,1.5) - 0.2*(z+0.3)/pow(x^2+y^2+(z+0.3)^2,1.5)'
rotate 40 60
light on
box
pipe ex ey ez 'bwr'

Pure C code

HMDT ex, ey, ez;
ex = mgl_create_data_size(10,10,10);
ey = mgl_create_data_size(10,10,10);
ez = mgl_create_data_size(10,10,10);
mgl_data_fill_eq(gr, ex, "0.2*x/pow(x^2+y^2+(z-0.3)^2,1.5) - \
        0.2*x/pow(x^2+y^2+(z+0.3)^2,1.5)",0,0);
mgl_data_fill_eq(gr, ey, "0.2*y/pow(x^2+y^2+(z-0.3)^2,1.5) - \
         0.2*y/pow(x^2+y^2+(z+0.3)^2,1.5)",0,0);
mgl_data_fill_eq(gr, ez, "0.2*(z-0.3)/pow(x^2+y^2+(z-0.3)^2,1.5) - \
         0.2*(z+0.3)/pow(x^2+y^2+(z+0.3)^2,1.5)",0,0);
mgl_rotate(gr,40.,60.,0.);
mgl_set_light(gr,1);
mgl_box(gr,1);
mgl_pipe_3d(gr,ex,ey,ez,"bwr",0.05,3,1);
mgl_delete_data(ex); mgl_delete_data(ey); mgl_delete_data(ez);

Fortran code

integer ex,ey,ez, mgl_create_data_size
ex = mgl_create_data_size(10,10,10)
ey = mgl_create_data_size(10,10,10)
ez = mgl_create_data_size(10,10,10)
call mgl_data_fill_eq(gr, ex, '0.2*x/pow(x^2+y^2+(z-0.3)^2,1.5) - &
        0.2*x/pow(x^2+y^2+(z+0.3)^2,1.5)',0,0);
call mgl_data_fill_eq(gr, ey, '0.2*y/pow(x^2+y^2+(z-0.3)^2,1.5) - &
         0.2*y/pow(x^2+y^2+(z+0.3)^2,1.5)',0,0);
call mgl_data_fill_eq(gr, ez, '0.2*(z-0.3)/pow(x^2+y^2+(z-0.3)^2,1.5) - &
         0.2*(z+0.3)/pow(x^2+y^2+(z+0.3)^2,1.5)',0,0);
call mgl_rotate(gr,40.,60.,0.)
call mgl_set_light(gr,1);
call mgl_box(gr,1);
call mgl_pipe_3d(gr,ex,ey,ez,'bwr',0.05,3,1)
call mgl_delete_data(ex)
call mgl_delete_data(ey)
call mgl_delete_data(ez)

Python

ex, ey, ez = mglData(10,10,10), mglData(10,10,10), mglData(10,10,10);
gr.Fill(ex, "0.2*x/pow(x^2+y^2+(z-0.3)^2,1.5) - \
        0.2*x/pow(x^2+y^2+(z+0.3)^2,1.5)");
gr.Fill(ey, "0.2*y/pow(x^2+y^2+(z-0.3)^2,1.5) - \
         0.2*y/pow(x^2+y^2+(z+0.3)^2,1.5)");
gr.Fill(ez, "0.2*(z-0.3)/pow(x^2+y^2+(z-0.3)^2,1.5) - \
         0.2*(z+0.3)/pow(x^2+y^2+(z+0.3)^2,1.5)");
gr.Rotate(40,60);   gr.Light(True);    gr.Box();
gr.Pipe(ex,ey,ez,"bwr");

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.4.19 Crust sample

png/crust

C++ code

mglData a("hotdogs.pts");
a.Norm(-1,1,true);
gr->Rotate(40,60);
gr->Light(true);
gr->Box();
gr->Crust(a,"p");

MGL code

read a 'hotdogs.pts'
norm a -1 1 on
rotate 40 60
light on
box
crust a 'p'

Pure C code

HMDT a = mgl_create_data_file("hotdogs.pts");
mgl_data_norm(a,-1.,1.,1,0);
mgl_rotate(gr,40.,60.,0.);
mgl_set_light(gr,1);
mgl_box(gr,1);
mgl_crust_tr(gr,a,"p",0.);
mgl_delete_data(a);

Fortran code

integer a, mgl_create_data_file
a = mgl_create_data_file("hotdogs.pts")
call mgl_data_norm(a,-1.,1.,1,0)
call mgl_rotate(gr,40.,60.,0.)
call mgl_set_light(gr,1)
call mgl_box(gr,1)
call mgl_crust_tr(gr,a,"p",0.)
call mgl_delete_data(a)

Python

a = mglData("hotdogs.pts");
a.Norm(-1,1,True);
gr.Rotate(40,60);   gr.Light(True);
gr.Box();
gr.Crust(a);

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.4.20 Dots sample

png/dots

C++ code

mglData a("hotdogs.pts");
a.Norm(-1,1,true);
gr->Rotate(40,60);
gr->Box();
gr->Dots(a,"p");

MGL code

read a 'hotdogs.pts'
norm a -1 1 on
rotate 40 60
box
dots a 'p'

Pure C code

HMDT a = mgl_create_data_file("hotdogs.pts");
mgl_data_norm(a,-1.,1.,1,0);
mgl_rotate(gr,40.,60.,0.);
mgl_box(gr,1);
mgl_dots_tr(gr,a,"p");
mgl_delete_data(a);

Fortran code

integer a, mgl_create_data_file
a = mgl_create_data_file("hotdogs.pts")
call mgl_data_norm(a,-1.,1.,1,0)
call mgl_rotate(gr,40.,60.,0.)
call mgl_box(gr,1)
call mgl_dots_tr(gr,a,"p")
call mgl_delete_data(a)

Python

a = mglData("hotdogs.pts");
a.Norm(-1,1,True);
gr.Rotate(40,60);   gr.Light(True);
gr.Box();
gr.Dots(a);

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.5 Basic features


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.5.1 1D plot sample

png/sample8

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

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.5.2 2D plot sample

png/sample9

C++ code

gr->Light(true);
mglData a0(50,40);
a0.Modify("0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))");
gr->SubPlot(2,2,0); gr->Rotate(60,40);
gr->Surf(a0);       gr->Box();

mglData x(50,40),y(50,40),z(50,40);
x.Modify("0.8*sin(2*pi*x)*sin(pi*y)");
y.Modify("0.8*cos(2*pi*x)*sin(pi*y)");
z.Modify("0.8*cos(pi*y)");
gr->SubPlot(2,2,1); gr->Rotate(60,40);
gr->Surf(x,y,z,"BbwrR");    gr->Box();

mglData a1(50,40,3);
a1.Modify("0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))");
a1.Modify("0.6*cos(2*pi*x)*cos(3*pi*y) + 0.4*sin(3*pi*(x*y))",1);
a1.Modify("0.6*cos(2*pi*x)*cos(3*pi*y) + 0.4*cos(3*pi*(x*y))",2);
gr->SubPlot(2,2,2); gr->Rotate(60,40);
gr->Alpha(true);
gr->Surf(a1);       gr->Box();

gr->SubPlot(2,2,3); gr->Rotate(60,40);
gr->Dens(a1);       gr->Box();

MGL code

light on

new a0 50 40
modify a0 '0.6*sin(2*pi*x)*sin(3*pi*y)+0.4*cos(3*pi*(x*y))'
subplot 2 2 0:rotate 60 40
surf a0: box

new x 50 40: new y 50 40: new z 50 40
modify x '0.8*sin(2*pi*x)*sin(pi*y)'
modify y '0.8*cos(2*pi*x)*sin(pi*y)'
modify z '0.8*cos(pi*y)'
subplot 2 2 1:rotate 60 40
surf x y z 'bbwrr': box

new a1 50 40 3
modify a1 '0.6*sin(2*pi*x)*sin(3*pi*y)+0.4*cos(3*pi*(x*y))'
modify a1 '0.6*cos(2*pi*x)*cos(3*pi*y)+0.4*sin(3*pi*(x*y))' 1
modify a1 '0.6*cos(2*pi*x)*cos(3*pi*y)+0.4*cos(3*pi*(x*y))' 2
subplot 2 2 2:rotate 60 40
alpha on
surf a1: box

subplot 2 2 3: rotate 60 40
dens a1: box

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.5.3 3D plot sample

png/sampleb

C++ code

gr->Alpha(true);	gr->Light(true);	gr->Light(0,mglPoint(0,0,1));
mglData a(30,30,30), b(30,30,30);
a.Modify("exp(-16*((z-0.5)^2+(y-0.5)^2)/(1+4*x^2))");
b.Modify("16*((z-0.5)^2+(y-0.5)^2)*(x)/(1+4*x^2)");
gr->CAxis(0,1);

gr->SubPlot(2,2,0);	gr->Rotate(40,60);
gr->Surf3(a,"wgk");	gr->Box();
gr->SubPlot(2,2,1);	gr->Rotate(40,60);
gr->DensA(a);		gr->Box();	gr->Axis();
gr->SubPlot(2,2,2);	gr->Rotate(40,60);
gr->Cloud(a);		gr->Box();
gr->SubPlot(2,2,3);	gr->Rotate(40,60);
gr->Surf3A(b,a,"q");		gr->Box();

MGL code

alpha on: light on
light 0 0 0 1
new a 30 30 30: new b 30 30 30
modify a 'exp(-16*((z-0.5)^2+(y-0.5)^2)/(1+4*x^2))'
modify b '16*((z-0.5)^2+(y-0.5)^2)*(x)/(1+4*x^2)'
caxis 0 1

subplot 2 2 0: rotate 40 60
surf3 a 'wgk': box
subplot 2 2 1: rotate 40 60
densa a: box: axis
subplot 2 2 2: rotate 40 60
cloud a: box
subplot 2 2 3: rotate 40 60
surf3a b a 'q': box

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.5.4 Line styles sample

png/sample5

C++ code

float d,x1,x2,x0,y=0.95;
d=0.3, x0=0.2, x1=0.5, x2=0.6;
gr->Line(mglPoint(x0,1-0*d),mglPoint(x1,1-0*d),"k-");	gr->Puts(mglPoint(x2,y-0*d),"Solid '-'","rL");
gr->Line(mglPoint(x0,1-1*d),mglPoint(x1,1-1*d),"k|");	gr->Puts(mglPoint(x2,y-1*d),"Long Dash '|'","rL");
gr->Line(mglPoint(x0,1-2*d),mglPoint(x1,1-2*d),"k;");	gr->Puts(mglPoint(x2,y-2*d),"Dash ';'","rL");
gr->Line(mglPoint(x0,1-3*d),mglPoint(x1,1-3*d),"k=");	gr->Puts(mglPoint(x2,y-3*d),"Small dash '='","rL");
gr->Line(mglPoint(x0,1-4*d),mglPoint(x1,1-4*d),"kj");	gr->Puts(mglPoint(x2,y-4*d),"Dash-dot 'j'","rL");
gr->Line(mglPoint(x0,1-5*d),mglPoint(x1,1-5*d),"ki");	gr->Puts(mglPoint(x2,y-5*d),"Small dash-dot 'i'","rL");
gr->Line(mglPoint(x0,1-6*d),mglPoint(x1,1-6*d),"k:");	gr->Puts(mglPoint(x2,y-6*d),"Dots ':'","rL");
gr->Line(mglPoint(x0,1-7*d),mglPoint(x1,1-7*d),"k ");	gr->Puts(mglPoint(x2,y-7*d),"None ' '","rL");

d=0.25; x1=-1; x0=-0.8;	y = -0.05;
gr->Mark(mglPoint(x1,5*d),'.');		gr->Puts(mglPoint(x0,y+5*d),"'.'","rL");
gr->Mark(mglPoint(x1,4*d),'+');		gr->Puts(mglPoint(x0,y+4*d),"'+'","rL");
gr->Mark(mglPoint(x1,3*d),'x');		gr->Puts(mglPoint(x0,y+3*d),"'x'","rL");
gr->Mark(mglPoint(x1,2*d),'*');		gr->Puts(mglPoint(x0,y+2*d),"'*'","rL");
gr->Mark(mglPoint(x1,d),'s');		gr->Puts(mglPoint(x0,y+d),"'s'","rL");
gr->Mark(mglPoint(x1,0),'d');		gr->Puts(mglPoint(x0,y),"'d'","rL");
gr->Mark(mglPoint(x1,-d,0),'o');	gr->Puts(mglPoint(x0,y-d),"'o'","rL");
gr->Mark(mglPoint(x1,-2*d,0),'^');	gr->Puts(mglPoint(x0,y-2*d),"'\\^'","rL");
gr->Mark(mglPoint(x1,-3*d,0),'v');	gr->Puts(mglPoint(x0,y-3*d),"'v'","rL");
gr->Mark(mglPoint(x1,-4*d,0),'<');	gr->Puts(mglPoint(x0,y-4*d),"'<'","rL");
gr->Mark(mglPoint(x1,-5*d,0),'>');	gr->Puts(mglPoint(x0,y-5*d),"'>'","rL");

d=0.25; x1=-0.5; x0=-0.3;	y = -0.05;
gr->Mark(mglPoint(x1,5*d),'C');		gr->Puts(mglPoint(x0,y+5*d),"'\\#.'","rL");
gr->Mark(mglPoint(x1,4*d),'P');		gr->Puts(mglPoint(x0,y+4*d),"'\\#+'","rL");
gr->Mark(mglPoint(x1,3*d),'X');		gr->Puts(mglPoint(x0,y+3*d),"'\\#x'","rL");
gr->Mark(mglPoint(x1,2*d),'Y');		gr->Puts(mglPoint(x0,y+2*d),"'\\#*'","rL");
gr->Mark(mglPoint(x1,d),'S');		gr->Puts(mglPoint(x0,y+d),"'\\#s'","rL");
gr->Mark(mglPoint(x1,0),'D');		gr->Puts(mglPoint(x0,y),"'\\#d'","rL");
gr->Mark(mglPoint(x1,-d,0),'O');	gr->Puts(mglPoint(x0,y-d),"'\\#o'","rL");
gr->Mark(mglPoint(x1,-2*d,0),'T');	gr->Puts(mglPoint(x0,y-2*d),"'\\#\\^'","rL");
gr->Mark(mglPoint(x1,-3*d,0),'V');	gr->Puts(mglPoint(x0,y-3*d),"'\\#v'","rL");
gr->Mark(mglPoint(x1,-4*d,0),'L');	gr->Puts(mglPoint(x0,y-4*d),"'\\#<'","rL");
gr->Mark(mglPoint(x1,-5*d,0),'R');	gr->Puts(mglPoint(x0,y-5*d),"'\\#>'","rL");

MGL code

NOT AVAILABLE

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.5.5 Arrow styles sample

png/sampled

C++ code

float a=0.1,b=0.4,c=0.5;
gr->Line(mglPoint(a,1),mglPoint(b,1),"k-A");		gr->Puts(mglPoint(c,1),"Style 'A' or 'A\\_'","rL");
gr->Line(mglPoint(a,0.8),mglPoint(b,0.8),"k-V");	gr->Puts(mglPoint(c,0.8),"Style 'V' or 'V\\_'","rL");
gr->Line(mglPoint(a,0.6),mglPoint(b,0.6),"k-K");	gr->Puts(mglPoint(c,0.6),"Style 'K' or 'K\\_'","rL");
gr->Line(mglPoint(a,0.4),mglPoint(b,0.4),"k-I");	gr->Puts(mglPoint(c,0.4),"Style 'I' or 'I\\_'","rL");
gr->Line(mglPoint(a,0.2),mglPoint(b,0.2),"k-D");	gr->Puts(mglPoint(c,0.2),"Style 'D' or 'D\\_'","rL");
gr->Line(mglPoint(a,0),mglPoint(b,0),"k-S");		gr->Puts(mglPoint(c,0),"Style 'S' or 'S\\_'","rL");
gr->Line(mglPoint(a,-0.2),mglPoint(b,-0.2),"k-O");	gr->Puts(mglPoint(c,-0.2),"Style 'O' or 'O\\_'","rL");
gr->Line(mglPoint(a,-0.4),mglPoint(b,-0.4),"k-T");	gr->Puts(mglPoint(c,-0.4),"Style 'T' or 'T\\_'","rL");
gr->Line(mglPoint(a,-0.6),mglPoint(b,-0.6),"k-_");	gr->Puts(mglPoint(c,-0.6),"Style '\\_' or none","rL");
gr->Line(mglPoint(a,-0.8),mglPoint(b,-0.8),"k-AS");	gr->Puts(mglPoint(c,-0.8),"Style 'AS'","rL");
gr->Line(mglPoint(a,-1),mglPoint(b,-1),"k-_A");		gr->Puts(mglPoint(c,-1),"Style '\\_A'","rL");

a=-1;	b=-0.7;	c=-0.6;
gr->Line(mglPoint(a,1),mglPoint(b,1),"kAA");		gr->Puts(mglPoint(c,1),"Style 'AA'","rL");
gr->Line(mglPoint(a,0.8),mglPoint(b,0.8),"kVV");	gr->Puts(mglPoint(c,0.8),"Style 'VV'","rL");
gr->Line(mglPoint(a,0.6),mglPoint(b,0.6),"kKK");	gr->Puts(mglPoint(c,0.6),"Style 'KK'","rL");
gr->Line(mglPoint(a,0.4),mglPoint(b,0.4),"kII");	gr->Puts(mglPoint(c,0.4),"Style 'II'","rL");
gr->Line(mglPoint(a,0.2),mglPoint(b,0.2),"kDD");	gr->Puts(mglPoint(c,0.2),"Style 'DD'","rL");
gr->Line(mglPoint(a,0),mglPoint(b,0),"kSS");		gr->Puts(mglPoint(c,0),"Style 'SS'","rL");
gr->Line(mglPoint(a,-0.2),mglPoint(b,-0.2),"kOO");	gr->Puts(mglPoint(c,-0.2),"Style 'OO'","rL");
gr->Line(mglPoint(a,-0.4),mglPoint(b,-0.4),"kTT");	gr->Puts(mglPoint(c,-0.4),"Style 'TT'","rL");
gr->Line(mglPoint(a,-0.6),mglPoint(b,-0.6),"k-__");	gr->Puts(mglPoint(c,-0.6),"Style '\\_\\_'","rL");
gr->Line(mglPoint(a,-0.8),mglPoint(b,-0.8),"k-VA");	gr->Puts(mglPoint(c,-0.8),"Style 'VA'","rL");
gr->Line(mglPoint(a,-1),mglPoint(b,-1),"k-AV");		gr->Puts(mglPoint(c,-1),"Style 'AV'","rL");

MGL code

NOT AVAILABLE

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.5.6 Text styles sample

png/sample4

C++ code

gr->Putsw(mglPoint(0,1),L"Text can be in ASCII and in Unicode");
gr->Puts(mglPoint(0,0.6),"It can be \\wire{wire}, \\big{big} or #r{colored}");
gr->Puts(mglPoint(0,0.2),"One can change style in string: "
        "\\b{bold}, \\i{italic, \\b{both}}");
gr->Puts(mglPoint(0,-0.2),"Easy to \\a{overline} or "
        "\\u{underline}");
gr->Puts(mglPoint(0,-0.6),"Easy to change indexes ^{up} _{down} @{center}");
gr->Puts(mglPoint(0,-1),"It parse TeX: \\int \\alpha \\cdot "
        "\\sqrt3{sin(\\pi x)^2 + \\gamma_{i_k}} dx");

MGL code

text 0 1 'Text can be in ASCII and in Unicode'
text 0 0.6 'It can be \wire{wire}, \big{big} or #r{colored}'
text 0 0.2 'One can change style in string: \b{bold}, \i{italic, \b{both}}'
text 0 -0.2 'Easy to \a{overline} or \u{underline}'
text 0 -0.6 'Easy to change indexes ^{up} _{down} @{center}'
text 0 -1 'It parse TeX: \int \alpha \cdot \sqrt3{sin(\pi x)^2 + \gamma_{i_k}} dx'

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.5.7 TeX parsing sample

png/samplee

C++ code

gr->Puts(mglPoint(0), "\\sqrt{\\frac{\\alpha^{\\gamma^2}+"
        "\\overset 1{\\big\\infty}}{\\sqrt3{2+b}}}", 0, -4);

MGL code

text 0 0 '\sqrt{\frac{\alpha^{\gamma^2}+\overset 1{\big\infty}}{\sqrt3{2+b}}}' '' -4

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.5.8 Font faces sample

png/fonts

C++ code

float h=1.1, d=0.25;
gr->LoadFont("STIX");		gr->Puts(mglPoint(0,h), "default font (STIX)");
gr->LoadFont("adventor");	gr->Puts(mglPoint(0,h-d), "adventor font");
gr->LoadFont("bonum");		gr->Puts(mglPoint(0,h-2*d), "bonum font");
gr->LoadFont("chorus");		gr->Puts(mglPoint(0,h-3*d), "chorus font");
gr->LoadFont("cursor");		gr->Puts(mglPoint(0,h-4*d), "cursor font");
gr->LoadFont("heros");		gr->Puts(mglPoint(0,h-5*d), "heros font");
gr->LoadFont("heroscn");	gr->Puts(mglPoint(0,h-6*d), "heroscn font");
gr->LoadFont("pagella");	gr->Puts(mglPoint(0,h-7*d), "pagella font");
gr->LoadFont("schola");		gr->Puts(mglPoint(0,h-8*d), "schola font");
gr->LoadFont("termes");		gr->Puts(mglPoint(0,h-9*d), "termes font");

MGL code

NOT AVAILABLE

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.5.9 Colors sample

png/colors

C++ code

//#LENUQ
gr->FaceZ(-1,	-1, 0, 0.4, 0.3, "L#");	gr->Puts(mglPoint(-0.8,-0.9), "L", "C:w", -1.4);
gr->FaceZ(-0.6,	-1, 0, 0.4, 0.3, "E#");	gr->Puts(mglPoint(-0.4,-0.9), "E", "C:w", -1.4);
gr->FaceZ(-0.2,	-1, 0, 0.4, 0.3, "N#");	gr->Puts(mglPoint(0,  -0.9), "N", "C:w", -1.4);
gr->FaceZ(0.2,	-1, 0, 0.4, 0.3, "U#");	gr->Puts(mglPoint(0.4,-0.9), "U", "C:w", -1.4);
gr->FaceZ(0.6,	-1, 0, 0.4, 0.3, "Q#");	gr->Puts(mglPoint(0.8,-0.9), "Q", "C:w", -1.4);
//#lenuq
gr->FaceZ(-1,	-0.7, 0, 0.4, 0.3, "l#");	gr->Puts(mglPoint(-0.8,-0.6), "l", "C:k", -1.4);
gr->FaceZ(-0.6,	-0.7, 0, 0.4, 0.3, "e#");	gr->Puts(mglPoint(-0.4,-0.6), "e", "C:k", -1.4);
gr->FaceZ(-0.2,	-0.7, 0, 0.4, 0.3, "n#");	gr->Puts(mglPoint(0,  -0.6), "n", "C:k", -1.4);
gr->FaceZ(0.2,	-0.7, 0, 0.4, 0.3, "u#");	gr->Puts(mglPoint(0.4,-0.6), "u", "C:k", -1.4);
gr->FaceZ(0.6,	-0.7, 0, 0.4, 0.3, "q#");	gr->Puts(mglPoint(0.8,-0.6), "q", "C:k", -1.4);
//#CMYkP
gr->FaceZ(-1,	-0.4, 0, 0.4, 0.3, "C#");	gr->Puts(mglPoint(-0.8,-0.3), "C", "C:w", -1.4);
gr->FaceZ(-0.6,	-0.4, 0, 0.4, 0.3, "M#");	gr->Puts(mglPoint(-0.4,-0.3), "M", "C:w", -1.4);
gr->FaceZ(-0.2,	-0.4, 0, 0.4, 0.3, "Y#");	gr->Puts(mglPoint(0,  -0.3), "Y", "C:w", -1.4);
gr->FaceZ(0.2,	-0.4, 0, 0.4, 0.3, "k#");	gr->Puts(mglPoint(0.4,-0.3), "k", "C:w", -1.4);
gr->FaceZ(0.6,	-0.4, 0, 0.4, 0.3, "P#");	gr->Puts(mglPoint(0.8,-0.3), "P", "C:w", -1.4);
//#cmywp
gr->FaceZ(-1,	-0.1, 0, 0.4, 0.3, "c#");	gr->Puts(mglPoint(-0.8, 0), "c", "C:k", -1.4);
gr->FaceZ(-0.6,	-0.1, 0, 0.4, 0.3, "m#");	gr->Puts(mglPoint(-0.4, 0), "m", "C:k", -1.4);
gr->FaceZ(-0.2,	-0.1, 0, 0.4, 0.3, "y#");	gr->Puts(mglPoint(0,   0), "y", "C:k", -1.4);
gr->FaceZ(0.2,	-0.1, 0, 0.4, 0.3, "w#");	gr->Puts(mglPoint(0.4, 0), "w", "C:k", -1.4);
gr->FaceZ(0.6,	-0.1, 0, 0.4, 0.3, "p#");	gr->Puts(mglPoint(0.8, 0), "p", "C:k", -1.4);
//#BGRHW
gr->FaceZ(-1,	0.2, 0, 0.4, 0.3, "B#");	gr->Puts(mglPoint(-0.8, 0.3), "B", "C:w", -1.4);
gr->FaceZ(-0.6,	0.2, 0, 0.4, 0.3, "G#");	gr->Puts(mglPoint(-0.4, 0.3), "G", "C:w", -1.4);
gr->FaceZ(-0.2,	0.2, 0, 0.4, 0.3, "R#");	gr->Puts(mglPoint(0,   0.3), "R", "C:w", -1.4);
gr->FaceZ(0.2,	0.2, 0, 0.4, 0.3, "H#");	gr->Puts(mglPoint(0.4, 0.3), "H", "C:w", -1.4);
gr->FaceZ(0.6,	0.2, 0, 0.4, 0.3, "W#");	gr->Puts(mglPoint(0.8, 0.3), "W", "C:w", -1.4);
//#bgrhw
gr->FaceZ(-1,	0.2, 0, 0.4, 0.3, "b#");	gr->Puts(mglPoint(-0.8, 0.6), "b", "C:k", -1.4);
gr->FaceZ(-0.6,	0.5, 0, 0.4, 0.3, "g#");	gr->Puts(mglPoint(-0.4, 0.6), "g", "C:k", -1.4);
gr->FaceZ(-0.2,	0.2, 0, 0.4, 0.3, "r#");	gr->Puts(mglPoint(0,   0.6), "r", "C:k", -1.4);
gr->FaceZ(0.2,	0.2, 0, 0.4, 0.3, "h#");	gr->Puts(mglPoint(0.4, 0.6), "h", "C:k", -1.4);
gr->FaceZ(0.6,	0.2, 0, 0.4, 0.3, "w#");	gr->Puts(mglPoint(0.8, 0.6), "w", "C:k", -1.4);
//#brighted
gr->FaceZ(-1,	0.8, 0, 0.4, 0.3, "r1#");	gr->Puts(mglPoint(-0.8, 0.9), "r1", "C:w", -1.4);
gr->FaceZ(-0.6,	0.8, 0, 0.4, 0.3, "r3#");	gr->Puts(mglPoint(-0.4, 0.9), "r3", "C:w", -1.4);
gr->FaceZ(-0.2,	0.8, 0, 0.4, 0.3, "r5#");	gr->Puts(mglPoint(0,   0.9), "r5", "C:k", -1.4);
gr->FaceZ(0.2,	0.8, 0, 0.4, 0.3, "r7#");	gr->Puts(mglPoint(0.4, 0.9), "r7", "C:k", -1.4);
gr->FaceZ(0.6,	0.8, 0, 0.4, 0.3, "r9#");	gr->Puts(mglPoint(0.8, 0.9), "r9", "C:k", -1.4);

MGL code

#LENUQ
facez -1   -1 0 0.4 0.3 'L#': text -0.8 -0.9 'L' 'C:w'
facez -0.6 -1 0 0.4 0.3 'E#': text -0.4 -0.9 'E' 'C:w'
facez -0.2 -1 0 0.4 0.3 'N#': text  0   -0.9 'N' 'C:w'
facez  0.2 -1 0 0.4 0.3 'U#': text  0.4 -0.9 'U' 'C:w'
facez  0.6 -1 0 0.4 0.3 'Q#': text  0.8 -0.9 'Q' 'C:w'
#lenuq
facez -1   -0.7 0 0.4 0.3 'l#': text -0.8 -0.6 'l' 'C:k'
facez -0.6 -0.7 0 0.4 0.3 'e#': text -0.4 -0.6 'e' 'C:k'
facez -0.2 -0.7 0 0.4 0.3 'n#': text  0   -0.6 'n' 'C:k'
facez  0.2 -0.7 0 0.4 0.3 'u#': text  0.4 -0.6 'u' 'C:k'
facez  0.6 -0.7 0 0.4 0.3 'q#': text  0.8 -0.6 'q' 'C:k'
#CMYkP
facez -1   -0.4 0 0.4 0.3 'C#': text -0.8 -0.3 'C' 'C:w'
facez -0.6 -0.4 0 0.4 0.3 'M#': text -0.4 -0.3 'M' 'C:w'
facez -0.2 -0.4 0 0.4 0.3 'Y#': text  0   -0.3 'Y' 'C:w'
facez  0.2 -0.4 0 0.4 0.3 'k#': text  0.4 -0.3 'k' 'C:w'
facez  0.6 -0.4 0 0.4 0.3 'P#': text  0.8 -0.3 'P' 'C:w'
#lenuq
facez -1   -0.1 0 0.4 0.3 'c#': text -0.8 0 'c' 'C:k'
facez -0.6 -0.1 0 0.4 0.3 'm#': text -0.4 0 'm' 'C:k'
facez -0.2 -0.1 0 0.4 0.3 'y#': text  0   0 'y' 'C:k'
facez  0.2 -0.1 0 0.4 0.3 'w#': text  0.4 0 'w' 'C:k'
facez  0.6 -0.1 0 0.4 0.3 'p#': text  0.8 0 'p' 'C:k'
#BGRHW
facez -1   0.2 0 0.4 0.3 'B#': text -0.8 0.3 'B' 'C:k'
facez -0.6 0.2 0 0.4 0.3 'G#': text -0.4 0.3 'G' 'C:k'
facez -0.2 0.2 0 0.4 0.3 'R#': text  0   0.3 'R' 'C:k'
facez  0.2 0.2 0 0.4 0.3 'H#': text  0.4 0.3 'H' 'C:k'
facez  0.6 0.2 0 0.4 0.3 'W#': text  0.8 0.3 'W' 'C:k'
#bgrhw
facez -1   0.5 0 0.4 0.3 'b#': text -0.8 0.6 'b' 'C:w'
facez -0.6 0.5 0 0.4 0.3 'g#': text -0.4 0.6 'g' 'C:w'
facez -0.2 0.5 0 0.4 0.3 'r#': text  0   0.6 'r' 'C:w'
facez  0.2 0.5 0 0.4 0.3 'h#': text  0.4 0.6 'h' 'C:w'
facez  0.6 0.5 0 0.4 0.3 'w#': text  0.8 0.6 'w' 'C:w'
#brighted
facez -1   0.8 0 0.4 0.3 'r1#': text -0.8 0.9 'r1' 'C:k'
facez -0.6 0.8 0 0.4 0.3 'r3#': text -0.4 0.9 'r3' 'C:k'
facez -0.2 0.8 0 0.4 0.3 'r5#': text  0   0.9 'r5' 'C:k'
facez  0.2 0.8 0 0.4 0.3 'r7#': text  0.4 0.9 'r7' 'C:k'
facez  0.6 0.8 0 0.4 0.3 'r9#': text  0.8 0.9 'r9' 'C:k'

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.5.10 Color schemes sample

png/color_schemes

C++ code

mglData a(256,2);	a.Fill(-1,1);
gr->SubPlot(2,10,0,0.2);	gr->Dens(a,"kw", nan);
gr->Puts(mglPoint(-1.4, -0.3), "kw", "C", -8);
gr->SubPlot(2,10,1,0.2);	gr->Dens(a,"wk", nan);
gr->Puts(mglPoint(-1.4, -0.3), "wk", "C", -8);
gr->SubPlot(2,10,2,0.2);	gr->Dens(a,"kHCcw", nan);
gr->Puts(mglPoint(-1.4, -0.3), "kHCcw", "C", -8);
gr->SubPlot(2,10,3,0.2);	gr->Dens(a,"kBbcw", nan);
gr->Puts(mglPoint(-1.4, -0.3), "kBbcw", "C", -8);
gr->SubPlot(2,10,4,0.2);	gr->Dens(a,"kRryw", nan);
gr->Puts(mglPoint(-1.4, -0.3), "kRryw", "C", -8);
gr->SubPlot(2,10,5,0.2);	gr->Dens(a,"kGgew", nan);
gr->Puts(mglPoint(-1.4, -0.3), "kGgew", "C", -8);
gr->SubPlot(2,10,6,0.2);	gr->Dens(a,"BbwrR", nan);
gr->Puts(mglPoint(-1.4, -0.3), "BbwrR", "C", -8);
gr->SubPlot(2,10,7,0.2);	gr->Dens(a,"BbwgG", nan);
gr->Puts(mglPoint(-1.4, -0.3), "BbwgG", "C", -8);
gr->SubPlot(2,10,8,0.2);	gr->Dens(a,"GgwmM", nan);
gr->Puts(mglPoint(-1.4, -0.3), "GgwmM", "C", -8);
gr->SubPlot(2,10,9,0.2);	gr->Dens(a,"UuwqR", nan);
gr->Puts(mglPoint(-1.4, -0.3), "UuwqR", "C", -8);
gr->SubPlot(2,10,10,0.2);	gr->Dens(a,"QqwcC", nan);
gr->Puts(mglPoint(-1.4, -0.3), "QqwcC", "C", -8);
gr->SubPlot(2,10,11,0.2);	gr->Dens(a,"CcwyY", nan);
gr->Puts(mglPoint(-1.4, -0.3), "CcwyY", "C", -8);
gr->SubPlot(2,10,12,0.2);	gr->Dens(a,"bcwyr", nan);
gr->Puts(mglPoint(-1.4, -0.3), "bcwyr", "C", -8);
gr->SubPlot(2,10,13,0.2);	gr->Dens(a,"bwr", nan);
gr->Puts(mglPoint(-1.4, -0.3), "bwr", "C", -8);
gr->SubPlot(2,10,14,0.2);	gr->Dens(a,"BbcyrR", nan);
gr->Puts(mglPoint(-1.4, -0.3), "BbcyrR", "C", -8);
gr->SubPlot(2,10,15,0.2);	gr->Dens(a,"UbcyqR", nan);
gr->Puts(mglPoint(-1.4, -0.3), "UbcyqR", "C", -8);
gr->SubPlot(2,10,16,0.2);	gr->Dens(a,"BbcwyrR", nan);
gr->Puts(mglPoint(-1.4, -0.3), "BbcwyrR", "C", -8);
gr->SubPlot(2,10,17,0.2);	gr->Dens(a,"bcyr", nan);
gr->Puts(mglPoint(-1.4, -0.3), "bcyr", "C", -8);
gr->SubPlot(2,10,18,0.2);	gr->Dens(a,"BbcyrR|", nan);
gr->Puts(mglPoint(-1.4, -0.3), "BbcyrR|", "C", -8);
gr->SubPlot(2,10,19,0.2);	gr->Dens(a,"bgr", nan);
gr->Puts(mglPoint(-1.4, -0.3), "bgr", "C", -8);

MGL code

new a 256 2: fill a 'x'
subplot 2 10 0 0.2:dens a 'kw'
text -1.4 -0.3 'kw' '' -8
subplot 2 10 1 0.2:dens a 'wk'
text -1.4 -0.3 'wk' '' -8
subplot 2 10 2 0.2:dens a 'kHCcw'
text -1.4 -0.3 'kHCcw' '' -8
subplot 2 10 3 0.2:dens a 'kBbcw'
text -1.4 -0.3 'kBbcw' '' -8
subplot 2 10 4 0.2:dens a 'kRryw'
text -1.4 -0.3 'kRryw' '' -8
subplot 2 10 5 0.2:dens a 'kGgew'
text -1.4 -0.3 'kGgew' '' -8
subplot 2 10 6 0.2:dens a 'BbwrR'
text -1.4 -0.3 'BbwrR' '' -8
subplot 2 10 7 0.2:dens a 'BbwgG'
text -1.4 -0.3 'BbwgG' '' -8
subplot 2 10 8 0.2:dens a 'GgwmM'
text -1.4 -0.3 'GgwmM' '' -8
subplot 2 10 9 0.2:dens a 'UuwqR'
text -1.4 -0.3 'UuwqR' '' -8
subplot 2 10 10 0.2:dens a 'QqwcC'
text -1.4 -0.3 'QqwcC' '' -8
subplot 2 10 11 0.2:dens a 'CcwyY'
text -1.4 -0.3 'CcwyY' '' -8
subplot 2 10 12 0.2:dens a 'bcwyr'
text -1.4 -0.3 'bcwyr' '' -8
subplot 2 10 13 0.2:dens a 'bwr'
text -1.4 -0.3 'bwr' '' -8
subplot 2 10 14 0.2:dens a 'BbcyrR'
text -1.4 -0.3 'BbcyrR' '' -8
subplot 2 10 15 0.2:dens a 'UbcyqR'
text -1.4 -0.3 'UbcyqR' '' -8
subplot 2 10 16 0.2:dens a 'BbcwyrR'
text -1.4 -0.3 'BbcwyrR' '' -8
subplot 2 10 17 0.2:dens a 'bcyr'
text -1.4 -0.3 'bcyr' '' -8
subplot 2 10 18 0.2:dens a 'BbcyrR|'
text -1.4 -0.3 'BbcyrR|' '' -8
subplot 2 10 19 0.2:dens a 'bgr'
text -1.4 -0.3 'bgr' '' -8

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.5.11 Normal transparency

png/type0

C++ code

gr->Alpha(true);	gr->Light(true);
mglData a(50,40);
a.Modify("0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))");

gr->TranspType = 0;	gr->Clf();
gr->SubPlot(2,2,0);	gr->Rotate(40,60);	gr->Surf(a);	gr->Box();
gr->SubPlot(2,2,1);	gr->Rotate(40,60);	gr->Dens(a);	gr->Box();
gr->SubPlot(2,2,2);	gr->Rotate(40,60);	gr->Cont(a);	gr->Box();
gr->SubPlot(2,2,3);	gr->Rotate(40,60);	gr->Axial(a);	gr->Box();

MGL code

alpha on: light on
new a 50 40
modify a '0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))'

transptype 0: clf
subplot 2 2 0: rotate 40 60: surf a:  box
subplot 2 2 1: rotate 40 60: dens a:  box
subplot 2 2 2: rotate 40 60: cont a:  box
subplot 2 2 3: rotate 40 60: axial a: box

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.5.12 Glass-like transparency

png/type1

C++ code

gr->Alpha(true);	gr->Light(true);
mglData a(50,40);
a.Modify("0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))");

gr->TranspType = 1;	gr->Clf();
gr->SubPlot(2,2,0);	gr->Rotate(40,60);	gr->Surf(a);	gr->Box();
gr->SubPlot(2,2,1);	gr->Rotate(40,60);	gr->Dens(a);	gr->Box();
gr->SubPlot(2,2,2);	gr->Rotate(40,60);	gr->Cont(a);	gr->Box();
gr->SubPlot(2,2,3);	gr->Rotate(40,60);	gr->Axial(a);	gr->Box();

MGL code

alpha on: light on
new a 50 40
modify a '0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))'

transptype 1: clf
subplot 2 2 0: rotate 40 60: surf a:  box
subplot 2 2 1: rotate 40 60: dens a:  box
subplot 2 2 2: rotate 40 60: cont a:  box
subplot 2 2 3: rotate 40 60: axial a: box

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.5.13 Lamp-like transparency

png/type2

C++ code

gr->Alpha(true);	gr->Light(true);
mglData a(50,40);
a.Modify("0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))");

gr->TranspType = 2;	gr->Clf();
gr->SubPlot(2,2,0);	gr->Rotate(40,60);	gr->Surf(a);	gr->Box();
gr->SubPlot(2,2,1);	gr->Rotate(40,60);	gr->Dens(a);	gr->Box();
gr->SubPlot(2,2,2);	gr->Rotate(40,60);	gr->Cont(a);	gr->Box();
gr->SubPlot(2,2,3);	gr->Rotate(40,60);	gr->Axial(a);	gr->Box();

MGL code

alpha on: light on
new a 50 40
modify a '0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))'

transptype 2: clf
subplot 2 2 0: rotate 40 60: surf a:  box
subplot 2 2 1: rotate 40 60: dens a:  box
subplot 2 2 2: rotate 40 60: cont a:  box
subplot 2 2 3: rotate 40 60: axial a: box

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.6 Additional features


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.6.1 Legend sample

png/legend

C++ code

mglData f(50,3);
f.Modify("sin(2*pi*x*x)",0);
f.Modify("sin(2*pi*x)",1);
f.Modify("sin(2*pi*sqrt(x))",2);
gr->Axis(mglPoint(0,-1),mglPoint(1,1));
gr->Box(); gr->Plot(f); gr->Axis();
gr->AddLegend("sin(\\pi {x^2})","b");
gr->AddLegend("sin(\\pi x)","g*");
gr->AddLegend("sin(\\pi \\sqrt{\\a x})","r+");
gr->Legend();

MGL code

new f 50 3
modify f 'sin(2*pi*x*x)'
modify f 'sin(2*pi*x)' 1
modify f 'sin(2*pi*sqrt(x))' 2
axis 0 -1 1 1
box
plot f
axis
addlegend 'sin(\pi {x^2})' 'b'
addlegend 'sin(\pi x)' 'g*'
addlegend 'sin(\pi \sqrt{\a x})' 'r+'
legend

Pure C code

HMDT f = mgl_create_data_size(50,3,1);
mgl_data_modify(f,"sin(2*pi*x*x)",0);
mgl_data_modify(f,"sin(2*pi*x)",1);
mgl_data_modify(f,"sin(2*pi*sqrt(x))",2);
mgl_set_axis(gr, 0.,-1.,0., 1.,1.,1., 0.,0.,0.);
mgl_box(gr,1);
mgl_plot(gr,f,NULL);
mgl_axis(gr,"xy");
mgl_add_legend(gr,"sin(\\pi {x^2})","b");
mgl_add_legend(gr,"sin(\\pi x)","g*");
mgl_add_legend(gr,"sin(\\pi \\sqrt{\\a x})","r+");
mgl_legend(gr,3,"rL",-1.,0.1);
mgl_delete_data(f);

Fortran code

integer f, mgl_create_data_size
f = mgl_create_data_size(50,3,1)
call mgl_data_modify(f,'sin(2*pi*x*x)',0)
call mgl_data_modify(f,'sin(2*pi*x)',1)
call mgl_data_modify(f,'sin(2*pi*sqrt(x))',2)
call mgl_set_axis(gr, 0.,-1.,0., 1.,1.,1., 0.,0.,0.)
call mgl_box(gr,1)
call mgl_plot(gr,f,'')
call mgl_axis(gr,'xy')
call mgl_add_legend(gr,'sin(\pi {x^2})','b');
call mgl_add_legend(gr,'sin(\pi x)','g*');
call mgl_add_legend(gr,'sin(\pi \sqrt{\a x})','r+');
call mgl_legend(gr,3,'rL',-1.,0.1);
call mgl_delete_data(f)

Python

f = mglData(50,3);
f.Modify("sin(2*pi*x*x)",0);    f.Modify("sin(2*pi*x)",1);      f.Modify("sin(2*pi*sqrt(x))",2);
gr.SetRanges(0,1,-1,1);     gr.Box();   gr.Axis();  gr.Plot(f);
gr.AddLegend("sin(\\pi x^2)","b");
gr.AddLegend("sin(\\pi x)","g*");
gr.AddLegend("sin(\\pi\\sqrt{\\a x})","r+");
gr.Legend();

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.6.2 Adding mesh sample

png/samplea

C++ code

mglData a(50,40);
a.Modify("0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))");
gr->Light(true);
gr->Alpha(true);
gr->SubPlot(2,2,0); gr->Rotate(40,60);
gr->Surf(a,"BbcyrR#");  gr->Box();
gr->SubPlot(2,2,1); gr->Rotate(40,60);
gr->Dens(a,"BbcyrR#");  gr->Box();
gr->SubPlot(2,2,2); gr->Rotate(40,60);
gr->Cont(a,"BbcyrR#");  gr->Box();
gr->SubPlot(2,2,3); gr->Rotate(40,60);
gr->Axial(a,"BbcyrR#"); gr->Box();

MGL code

new a 50 40
modify a '0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))'
alpha on
light on
subplot 2 2 0
rotate 40 60
surf a 'BbcyrR#'
box
subplot 2 2 1
rotate 40 60
dens a 'BbcyrR#'
box
subplot 2 2 2
rotate 40 60
cont a 'BbcyrR#'
box
subplot 2 2 3
rotate 40 60
axial a 'BbcyrR#'
box

Pure C code

HMDT a = mgl_create_data_size(50,40,1);
mgl_data_modify(a,"0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))",0);
mgl_set_alpha(gr,1);
mgl_set_light(gr,1);
mgl_subplot(gr,2,2,0); mgl_rotate(gr,40.,60.,0.);
mgl_surf(gr,a,"BbcyrR#");       mgl_box(gr,1);
mgl_subplot(gr,2,2,1); mgl_rotate(gr,40.,60.,0.);
mgl_dens(gr,a,"BbcyrR#",-1.);   mgl_box(gr,1);
mgl_subplot(gr,2,2,2); mgl_rotate(gr,40.,60.,0.);
mgl_cont(gr,a,"BbcyrR#",7,NAN); mgl_box(gr,1);
mgl_subplot(gr,2,2,3); mgl_rotate(gr,40.,60.,0.);
mgl_axial(gr,a,"BbcyrR#",3);    mgl_box(gr,1);
mgl_delete_data(a);

Fortran code

integer a, mgl_create_data_size
real zero, nan
zero=0; nan=zero/zero
a = mgl_create_data_size(50,40,1)
call mgl_data_modify(a,'0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))',0)
call mgl_set_alpha(gr,1)
call mgl_set_light(gr,1)
call mgl_subplot(gr,2,2,0)
call mgl_rotate(gr,40.,60.,0.)
call mgl_surf(gr,a,'BbcyrR#')
call mgl_box(gr,1)
call mgl_subplot(gr,2,2,1)
call mgl_rotate(gr,40.,60.,0.)
call mgl_dens(gr,a,'BbcyrR#',-1.)
call mgl_box(gr,1)
call mgl_subplot(gr,2,2,2)
call mgl_rotate(gr,40.,60.,0.)
call mgl_cont(gr,a,'BbcyrR#',7,nan)
call mgl_box(gr,1)
call mgl_subplot(gr,2,2,3)
call mgl_rotate(gr,40.,60.,0.)
call mgl_axial(gr,a,'BbcyrR#',3)
call mgl_box(gr,1)
call mgl_delete_data(a)

Python

a = mglData(50,40);
a.Modify("0.6*sin(2*pi*x)*sin(3*pi*y)+0.4*cos(3*pi*(x*y))");
gr.Light(True);     gr.Alpha(True);
gr.SubPlot(2,2,0);
gr.Rotate(40,60);   gr.Surf(a,"BbcyrR#");   gr.Box();
gr.SubPlot(2,2,1);
gr.Rotate(40,60);   gr.Dens(a,"BbcyrR#");   gr.Box();
gr.SubPlot(2,2,2);
gr.Rotate(40,60);   gr.Cont(a,"BbcyrR#");   gr.Box();
gr.SubPlot(2,2,3);
gr.Rotate(40,60);   gr.Axial(a,"BbcyrR#");  gr.Box();

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.6.3 Surf & Cont sample

png/surf_cont_y

C++ code

mglData a(50,40);
a.Modify("0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))");
gr->Rotate(40,60);
gr->Light(true);
gr->Box();
gr->Surf(a);
gr->Cont(a,"y");

MGL code

new a 50 40
modify a '0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))'
rotate 40 60
light on
box
surf a
cont a 'y'

Pure C code

HMDT a = mgl_create_data_size(50,40,1);
mgl_data_modify(a,"0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))",0);
mgl_rotate(gr,40.,60.,0.);
mgl_set_light(gr,1);
mgl_box(gr,1);
mgl_surf(gr,a,0);
mgl_cont(gr,a,"y",7,NAN);
mgl_delete_data(a);

Fortran code

integer a, mgl_create_data_size
real zero, nan
zero = 0; nan = zero/zero
a = mgl_create_data_size(50,40,1)
call mgl_data_modify(a,"0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))",0)
call mgl_rotate(gr,40.,60.,0.)
call mgl_set_light(gr,1)
call mgl_box(gr,1)
call mgl_surf(gr,a,'')
call mgl_cont(gr,a,'y',7,nan)
call mgl_delete_data(a)

Python

a = mglData(50,40);
a.Modify("0.6*sin(2*pi*x)*sin(3*pi*y)+0.4*cos(3*pi*(x*y))");
gr.Rotate(40,60);   gr.Light(True);
gr.Box();
gr.Surf(a);         gr.Cont(a,"y");

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.6.4 Flow & Dens sample

png/flow_dens

C++ code

mglData a(50,40), b(50,40), d(a);
a.Modify("0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))");
b.Modify("0.6*cos(2*pi*x)*cos(3*pi*y) + 0.4*cos(3*pi*(x*y))");
d.Modify("sqrt(v^2+w^2)",a,b);
gr->Box();
gr->Flow(a,b,"br"); gr->Dens(d,"BbcyrR");

MGL code

new a 50 40
new b 50 40
modify a '0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))'
modify b '0.6*cos(2*pi*x)*cos(3*pi*y) + 0.4*cos(3*pi*(x*y))'
copy d a
modify d 'sqrt(v^2+w^2)' a b
box
flow a b 'br'
dens d 'BbcyrR'

Pure C code

HMDT a, b, d;
a = mgl_create_data_size(50,40,1);
b = mgl_create_data_size(50,40,1);
d = mgl_create_data_size(50,40,1);
mgl_data_modify(a,"0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))",0);
mgl_data_modify(b,"0.6*cos(2*pi*x)*cos(3*pi*y) + 0.4*cos(3*pi*(x*y))",0);
mgl_data_modify(d,"sqrt(v^2+w^2)",a,b);
mgl_box(gr,1);
mgl_flow_2d(gr,a,b,"br",5,1,0.);
mgl_dens(gr,d,"BbcyrR",-1.);
mgl_delete_data(a); mgl_delete_data(b); mgl_delete_data(d);

Fortran code

integer a,b,d, mgl_create_data_size
a = mgl_create_data_size(50,40,1);
b = mgl_create_data_size(50,40,1);
d = mgl_create_data_size(50,40,1);
call mgl_data_modify(a,"0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))",0);
call mgl_data_modify(b,"0.6*cos(2*pi*x)*cos(3*pi*y) + 0.4*cos(3*pi*(x*y))",0);
call mgl_data_modify(d,"sqrt(v^2+w^2)",a,b);
call mgl_box(gr,1)
call mgl_flow_2d(gr,a,b,'br',5,1,0.)
call mgl_dens(gr,d,'BbcyrR',-1.);
call mgl_delete_data(a)
call mgl_delete_data(b)
call mgl_delete_data(d)

Python

a, b= mglData(50,40), mglData(50,40);   d = mglData(a)
a.Modify("0.6*sin(2*pi*x)*sin(3*pi*y)+0.4*cos(3*pi*(x*y))");
b.Modify("0.6*cos(2*pi*x)*cos(3*pi*y)+0.4*cos(3*pi*(x*y))");
d.Modify("sqrt(v^2+w^2)",a,b);
gr.Box();
gr.Flow(a,b,"br");      gr.Dens(d,"BbcyrR");

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.6.5 Several light sample

png/several_light

C++ code

mglData a(50,40);
a.Modify("0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))");
gr->Rotate(40,60);
gr->Light(true);
gr->Light(1,mglPoint(0,1,0),'c');
gr->Light(2,mglPoint(1,0,0),'y');
gr->Light(3,mglPoint(0,-1,0),'m');
gr->Box();
gr->Surf(a,"h");

MGL code

new a 50 40
modify a '0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))'
rotate 40 60
light on
light 1 0 1 0 'c'
light 2 1 0 0 'y'
light 3 0 -1 0 'm'
box
surf a 'h'

Pure C code

HMDT a = mgl_create_data_size(50,40,1);
mgl_data_modify(a,"0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))",0);
mgl_rotate(gr,40.,60.,0.);
mgl_set_light(gr,1);
mgl_add_light_rgb(gr,1,0.,1.,0.,1, 0.,1.,1.,0.5);
mgl_add_light_rgb(gr,2,1.,0.,0.,1, 1.,1.,0.,0.5);
mgl_add_light_rgb(gr,3,0.,-1.,0.,1, 1.,0.,1.,0.5);
mgl_box(gr,1);
mgl_surf(gr,a,"h");
mgl_delete_data(a);

Fortran code

integer a, mgl_create_data_size
a = mgl_create_data_size(50,40,1);
call mgl_data_modify(a,"0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))",0);
call mgl_rotate(gr,40.,60.,0.)
call mgl_set_light(gr,1)
call mgl_add_light_rgb(gr,1,0.,1.,0.,1, 0.,1.,1.,0.5)
call mgl_add_light_rgb(gr,2,1.,0.,0.,1, 1.,1.,0.,0.5)
call mgl_add_light_rgb(gr,3,0.,-1.,0.,1, 1.,0.,1.,0.5)
call mgl_box(gr,1)
call mgl_surf(gr,a,'h')
call mgl_delete_data(a)

Python

a = mglData(50,40);
a.Modify("0.6*sin(2*pi*x)*sin(3*pi*y)+0.4*cos(3*pi*(x*y))");
gr.Rotate(40,60);       gr.Light(True);
gr.AddLight(1,0,1,0,"c");
gr.AddLight(2,1,0,0,"y");
gr.AddLight(3,0,-1,0,"m");
gr.Box();
gr.Surf(a,"h")

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.6.6 Mirrored surface sample

png/mirror

C++ code

mglData a(30,40),x(30),y1(40),y2(40);
a.Modify("pi*(1-2*x)*exp(-4*y^2-4*(2*x-1)^2)");
x.Fill(-1,1); y1.Fill(0,1); y2.Fill(0,-1);
gr->Rotate(40,60);
gr->Light(true);
gr->Box();
gr->Surf(x,y1,a,"r"); gr->Surf(x,y2,a,"b");

MGL code

new a 30 40
modify a 'pi*(1-2*x)*exp(-4*y^2-4*(2*x-1)^2)'
rotate 40 60
light on
surf a 'r'; yrange 0 1
surf a 'b'; yrange 0 -1
box

or

new a 30 40
var x 30 -1 1
var y1 40 0 1
var y2 40 0 -1
modify a 'pi*(1-2*x)*exp(-4*y^2-4*(2*x-1)^2)'
rotate 40 60
light on
surf x y1 a 'r'
surf x y2 a 'b'
box

Pure C code

HMDT a,x,y1,y2;
a = mgl_create_data_size(30,40,1);
x = mgl_create_data_size(30,1,1);
y1 = mgl_create_data_size(40,1,1);
y2 = mgl_create_data_size(40,1,1);
mgl_data_modify(a,"pi*(1-2*x)*exp(-4*y^2-4*(2*x-1)^2)",0);
mgl_data_fill(x,-1.,1.,'x');
mgl_data_fill(y1,0.,1.,'x');
mgl_data_fill(y2,0.,-1.,'x');
mgl_rotate(gr,40.,60.,0.);
mgl_set_light(gr,1);
mgl_box(gr,1);
mgl_surf_xy(gr,x,y1,a,"r"); mgl_surf_xy(gr,x,y2,a,"b");
mgl_delete_data(a); mgl_delete_data(y1);
mgl_delete_data(x); mgl_delete_data(y2);

Fortran code

integer a,x,y1,y2, mgl_create_data_size
a = mgl_create_data_size(30,40,1)
x = mgl_create_data_size(30,1,1)
y1 = mgl_create_data_size(40,1,1)
y2 = mgl_create_data_size(40,1,1)
call mgl_data_modify(a,'pi*(1-2*x)*exp(-4*y^2-4*(2*x-1)^2)',0)
call mgl_data_fill(x,-1.,1.,'x')
call mgl_data_fill(y1,0.,1.,'x')
call mgl_data_fill(y2,0.,-1.,'x')
call mgl_rotate(gr,40.,60.,0.)
call mgl_set_light(gr,1)
call mgl_box(gr,1)
call mgl_surf_xy(gr,x,y1,a,'r')
call mgl_surf_xy(gr,x,y2,a,'b')
call mgl_delete_data(a)
call mgl_delete_data(y1)
call mgl_delete_data(x)
call mgl_delete_data(y2)

Python

a, x, y1, y2 = mglData(30,40), mglData(30), mglData(40), mglData(40);
a.Modify("pi*(1-2*x)*exp(-4*y^2-4*(2*x-1)^2)");
x.Fill(-1,1);   y1.Fill(0,1);   y2.Fill(0,-1);
gr.Rotate(40,60);       gr.Light(True);         gr.Box();
gr.Surf(x,y1,a,"r");    gr.Surf(x,y2,a,"b");

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.6.7 Cont with labels sample

png/contt

C++ code

mglData a(50,40);
a.Modify("0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))");
gr->Box();
gr->Cont(a,"BbcyrRt");

MGL code

new a 50 40
modify a '0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))'
box
cont a 'BbcyrRt'

Pure C code

HMDT a = mgl_create_data_size(50,40,1);
mgl_data_modify(a,"0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))",0);
mgl_box(gr,1);
mgl_cont(gr,a,"BbcyrRt",7,0);
mgl_delete_data(a);

Fortran code

integer a, mgl_create_data_size
a = mgl_create_data_size(50,40,1);
call mgl_data_modify(a,"0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))",0);
call mgl_box(gr,1)
call mgl_cont(gr,a,'BbcyrRt',7,0)
call mgl_delete_data(a)

Python

a = mglData(50,40);
a.Modify("0.6*sin(2*pi*x)*sin(3*pi*y)+0.4*cos(3*pi*(x*y))");
gr.Box();
gr.Cont(a,"BbcyrRt");

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.6.8 Ternary plot sample

png/ternary

C++ code

mglData x(50),y(50),rx(10),ry(10), a(20,30);
a.Modify("4*x*y");
x.Modify("0.25*(1+cos(2*pi*x))");
y.Modify("0.25*(1+sin(2*pi*x))");
rx.Modify("rnd"); ry.Modify("(1-v)*rnd",rx);
gr->Text(mglPoint(-0.8,1.3), "Ternary plot (x+y+t=1)");
gr->Ternary(1);
gr->Plot(x,y,"r2");
gr->Plot(rx,ry,"q^ ");
gr->Cont(a);
gr->Line(mglPoint(0.5,0), mglPoint(0,0.75), "g2");
gr->Axis(); gr->Grid("xyz","B;");
gr->Label('x',"x comp.");
gr->Label('y',"y comp.");
gr->Label('t',"t comp.");

MGL code

new rx 10
new ry 10
new x 50
new y 50
new a 20 30
modify a '4*x*y'
modify x '0.25*(1+cos(2*pi*x))'
modify y '0.25*(1+sin(2*pi*x))'
modify rx 'rnd'
modify ry 'rnd*(1-v)' rx
text -0.8 1.3 'Ternary plot (x+y+t=1)'
ternary 1
plot x y 'r2'
plot rx ry 'q^ '
cont a
line 0.5 0 0 0.75 'g2'
axis
grid 'xyz' 'B;'
xlabel 'x comp.'
ylabel 'y comp.'
tlabel 't comp.'

Pure C code

HMDT x,y,rx,ry,a;
x = mgl_create_data_size(50,1,1);
y = mgl_create_data_size(50,1,1);
rx = mgl_create_data_size(50,1,1);
ry = mgl_create_data_size(50,1,1);
a = mgl_create_data_size(20,30,1);
mgl_data_modify(x,"0.25*(1+cos(2*pi*x))",0);
mgl_data_modify(y,"0.25*(1+sin(2*pi*x))",0);
mgl_data_modify(rx,"rnd",0);
mgl_data_modify_vw(ry,"(1-v)*rnd",rx,0);
mgl_data_modify(a,"4*x*y",0);
mgl_puts_ext(gr,-0.8,1.3,0.,"Ternary plot (x+y+t=1)","C",-1.4,'t');
mgl_set_ternary(gr,1);
mgl_plot_xy(gr,x,y,"r2");
mgl_plot_xy(gr,rx,ry,"q^ ");
mgl_cont(gr,a,"",7,0.);
mgl_line(gr,0.5,0.,0.,0.,0.75,0.,"g2",2);
mgl_axis(gr,"xyz");
mgl_axis_grid(gr,"xyz","B:");
mgl_label(gr,'x',"x comp");
mgl_label(gr,'y',"y comp");
mgl_label(gr,'t',"t comp");
mgl_delete_data(a);
mgl_delete_data(x);     mgl_delete_data(y);
mgl_delete_data(rx);    mgl_delete_data(ry);

Fortran code

integer a,x,y,rx,ry, mgl_create_data_size
x = mgl_create_data_size(50,1,1)
y = mgl_create_data_size(50,1,1)
rx = mgl_create_data_size(50,1,1)
ry = mgl_create_data_size(50,1,1)
a = mgl_create_data_size(20,30,1)
call mgl_data_modify(x,'0.25*(1+cos(2*pi*x))',0)
call mgl_data_modify(y,'0.25*(1+sin(2*pi*x))',0)
call mgl_data_modify(rx,'rnd',0)
call mgl_data_modify_vw(ry,'(1-v)*rnd',rx,rx)
call mgl_data_modify(a,'4*x*y',0)
call mgl_puts_ext(gr,-0.8,1.3,0.,'Ternary plot (x+y+t=1)','C',-1.4,'t')
call mgl_set_ternary(gr,1)
call mgl_plot_xy(gr,x,y,'r2')
call mgl_plot_xy(gr,rx,ry,'q^ ')
call mgl_cont(gr,a,'',7,0.)
call mgl_line(gr,0.5,0.,0.,0.,0.75,0.,'g2',2)
call mgl_axis(gr,'xyz')
call mgl_axis_grid(gr,'xyz','B:')
call mgl_label(gr,'x','x comp')
call mgl_label(gr,'y','y comp')
call mgl_label(gr,'t','t comp')
call mgl_delete_data(a)
call mgl_delete_data(x)
call mgl_delete_data(y)
call mgl_delete_data(rx)
call mgl_delete_data(ry)

Python

x, y, rx, ry, a = mglData(50), mglData(50), mglData(10), mglData(10), mglData(20,30);
a.Modify("4*x*y");
x.Modify("0.25*(1+cos(2*pi*x))");   y.Modify("0.25*(1+sin(2*pi*x))");
rx.Modify("rnd");   ry.Modify("(1-v)*rnd",rx);
gr.Puts(-0.8,1.3,0,"Ternary plot (x+y+t=1)","C",-1.4);
gr.Ternary(1);
gr.Plot(x,y,"r2");  gr.Plot(rx,ry,"q^ ");   gr.Cont(a);
gr.Line(0.5,0,0,0,0.75,0,"g2");
gr.Axis();          gr.Grid("xyz","B;");
gr.Label("x","x comp.");
gr.Label("y","y comp.");
gr.Label("t","t comp.");

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.6.9 Quaternary plot sample

png/quaternary

C++ code

mglData x(50),y(50),z(50),rx(10),ry(10), a(20,30);
a.Modify("x*y*(1-x-y)^2*30");
x.Modify("0.25*(1-x)*(1+cos(2*pi*x))");
y.Modify("0.25*(1-x)*(1+sin(2*pi*x))");
z.Modify("x");

gr->Text(mglPoint(0,1.3), "Quaternary plot (x+y+z+t=1)");
gr->Rotate(60,70);      gr->Light(true);
gr->Ternary(2);         gr->SetCut(true);
gr->Plot(x,y,z,"r2");	gr->Surf(a,"#");
gr->Axis(); gr->Grid();	gr->Box();
gr->SetRotatedText(false);
gr->Label('t',"A",1);	gr->Label('x',"B",1);
gr->Label('y',"C",1);	gr->Label('z',"D",1);

MGL code

new x 50:new y 50:new z 50:new a 20 30
modify a 'x*y*(1-x-y)^2*30'
modify x '0.25*(1-x)*(1+cos(2*pi*x))'
modify y '0.25*(1-x)*(1+sin(2*pi*x))'

text 0 1.3 'Quaternary plot (x+y+z+t=1)'
rotate 60 70:light on
ternary 2:cut on
plot x y z 'r2':surf a '#'
axis:box:grid
rotatetext off
tlabel 'A' 1:xlabel 'B' 1
ylabel 'C' 1:zlabel 'D' 1

Pure C code

TO BE DONE

Fortran code

TO BE DONE

Python

x, y, z, a = mglData(50), mglData(50), mglData(50), mglData(20,30);
a.Modify("x*y*(1-x-y)^2*30");
x.Modify("0.25*(1-x)*(1+cos(2*pi*x))");
y.Modify("0.25*(1-x)*(1+sin(2*pi*x))");
z.Modify("x");

gr.Text(mglPoint(0,1.3), "Quaternary plot (x+y+z+t=1)");
gr.Rotate(60,70);       gr.Light(True);
gr.Ternary(2);          gr.SetCut(True);
gr.Plot(x,y,z,"r2");    gr.Surf(a,"#");
gr.Axis(); gr->Grid();  gr.Box();
gr.SetRotatedText(0);
gr.Label('t',"A",1);    gr.Label('x',"B",1);
gr.Label('y',"C",1);    gr.Label('z',"D",1);

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.6.10 Coloring by coordinates sample

png/surf3_rgbd

C++ code

mglData a(60,50,40);
a.Modify("-2*((2*x-1)^2 + (2*y-1)^2 + (2*z-1)^4 - (2*z-1)^2 - 0.1)");
gr->Rotate(40,60);
gr->Box();
gr->Surf3(a,"bgrd");

MGL code

new a 60 50 40
modify a '-2*((2*x-1)^2 + (2*y-1)^2 + (2*z-1)^4 - (2*z-1)^2 - 0.1)'
rotate 40 60
box
surf3 a 'bgrd'

Pure C code

HMDT a = mgl_create_data_size(60,50,40);
mgl_data_modify(a,"-2*((2*x-1)^2 + (2*y-1)^2 + (2*z-1)^4 - (2*z-1)^2 - 0.1)",0);
mgl_rotate(gr,40.,60.,0.);
mgl_box(gr,1);
mgl_surf3(gr,a,"bgrd",3);
mgl_delete_data(a);

Fortran code

integer a, mgl_create_data_size
a = mgl_create_data_size(60,50,40);
call mgl_data_modify(a,"-2*((2*x-1)^2 + (2*y-1)^2 + (2*z-1)^4 - (2*z-1)^2 - 0.1)",0);
call mgl_rotate(gr,40.,60.,0.)
call mgl_box(gr,1)
call mgl_surf3(gr,a,'bgrd',3)
call mgl_delete_data(a)

Python

a = mglData(60,50,40);
a.Modify("-2*((2*x-1)^2+(2*y-1)^2+(2*z-1)^4-(2*z-1)^2-0.1)");
gr.Rotate(40,60);       gr.Box();
gr.Surf3(a,"bgrd");

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.6.11 Drops sample

png/drops

C++ code

gr->Light(true);
gr->Puts(mglPoint(-1,1.2),"sh=0");
gr->Drop(mglPoint(-1,0),mglPoint(0,1),0.5,"r",0);
gr->Puts(mglPoint(-0.33,1.2),"sh=0.33");
gr->Drop(mglPoint(-0.33,0),mglPoint(0,1),0.5,"r",0.33);
gr->Puts(mglPoint(0.33,1.2),"sh=0.67");
gr->Drop(mglPoint(0.33,0),mglPoint(0,1),0.5,"r",0.67);
gr->Puts(mglPoint(1,1.2),"sh=1");
gr->Drop(mglPoint(1,0),mglPoint(0,1),0.5,"r",1);
gr->Ball(mglPoint(-1,0,1),'k');
gr->Ball(mglPoint(-0.33,0,1),'k');
gr->Ball(mglPoint(0.33,0,1),'k');
gr->Ball(mglPoint(1,0,1),'k');
gr->Line(mglPoint(-1,0,1),mglPoint(1,0,1),"b");

MGL code

light on
text -1 1.2 'sh=0'
drop -1 0 0 1 0.5 'r' 0
text -0.33 1.2 'sh=0.33'
drop -0.33 0 0 1 0.5 'r' 0.33
text 0.33 1.2 'sh=0.67'
drop 0.33 0 0 1 0.5 'r' 0.67
text 1 1.2 'sh=1'
drop 1 0 0 1 0.5 'r' 1
ball -1 0 1 'k'
ball -0.33 0 1 'k'
ball 0.33 0 1 'k'
ball 1 0 1 'k'
line -1 0 1 1 0 1 'b'
new h 100
modify h '0.25*(1+x)^2'
plot h 'k|'
text -1 0.6 'h\sim(1+sh)^2' 'rL'

Pure C code

mgl_set_light(gr,1);
mgl_puts(gr,-1.,1.2,0.,"sh=0"); 
mgl_drop(gr,-1.,0.,0.,0.,1.,0.,0.5,"r",0.,1.);
mgl_puts(gr,-0.33,1.2,0.,"sh=0.33"); 
mgl_drop(gr,-0.33,0.,0.,0.,1.,0.,0.5,"r",0.33,1.);
mgl_puts(gr,0.33,1.2,0.,"sh=0.67"); 
mgl_drop(gr,0.33,0.,0.,0.,1.,0.,0.5,"r",0.67,1.);
mgl_puts(gr,1.,1.2,0.,"sh=1"); 
mgl_drop(gr,1.,0.,0.,0.,1.,0.,0.5,"r",1.,1.);
mgl_ball_str(gr,-1.,0.,1.,"k");
mgl_ball_str(gr,-0.33,0.,1.,"k");
mgl_ball_str(gr,0.33,0.,1.,"k");
mgl_ball_str(gr,1.,0.,1.,"k");
mgl_line(gr,-1.,0.,1.,1.,0.,1.,"b",2);

Fortran code

call mgl_set_light(gr,1);
call mgl_puts(gr,-1.,1.2,0.,"sh=0"); 
call mgl_drop(gr,-1.,0.,0.,0.,1.,0.,0.5,"r",0.,1.);
call mgl_puts(gr,-0.33,1.2,0.,"sh=0.33"); 
call mgl_drop(gr,-0.33,0.,0.,0.,1.,0.,0.5,"r",0.33,1.);
call mgl_puts(gr,0.33,1.2,0.,"sh=0.67"); 
call mgl_drop(gr,0.33,0.,0.,0.,1.,0.,0.5,"r",0.67,1.);
call mgl_puts(gr,1.,1.2,0.,"sh=1"); 
call mgl_drop(gr,1.,0.,0.,0.,1.,0.,0.5,"r",1.,1.);
call mgl_ball_str(gr,-1.,0.,1.,"k");
call mgl_ball_str(gr,-0.33,0.,1.,"k");
call mgl_ball_str(gr,0.33,0.,1.,"k");
call mgl_ball_str(gr,1.,0.,1.,"k");
call mgl_line(gr,-1.,0.,1.,1.,0.,1.,"b",2);

Python

gr.Light(True);
gr.Puts(-1,1.2,0,"sh=0","rC");
gr.Drop(-1,0,0,0,1,0,0.5,"r",0);
gr.Puts(-0.33,1.2,0,"sh=0.33","rC");
gr.Drop(-0.33,0,0,0,1,0,0.5,"r",0.33);
gr.Puts(0.33,1.2,0,"sh=0.67","rC");
gr.Drop(0.33,0,0,0,1,0,0.5,"r",0.67);
gr.Puts(1,1.2,0,"sh=1","rC");
gr.Drop(1,0,0,0,1,0,0.5,"r",1);
gr.Ball(-1,0,1,"k");    gr.Ball(-0.33,0,1,"k");
gr.Ball(0.33,0,1,"k");  gr.Ball(1,0,1,"k");
gr.Line(-1,0,1,1,0,1,"b");

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.6.12 Molecules drawing sample

png/molecule

C++ code

gr->Alpha(true); gr->Light(true);
gr->SubPlot(2,2,0);
gr->Text(mglPoint(0,1.2),"Methane, CH_4",0,-3); gr->Rotate(60,120);
gr->Sphere(mglPoint(0,0,0),0.25,"k");
gr->Drop(mglPoint(0,0,0),mglPoint(0,0,1),0.35,"h",1,2);
gr->Sphere(mglPoint(0,0,0.7),0.25,"g");
gr->Drop(mglPoint(0,0,0),mglPoint(-0.94,0,-0.33),0.35,"h",1,2);
gr->Sphere(mglPoint(-0.66,0,-0.23),0.25,"g");
gr->Drop(mglPoint(0,0,0),mglPoint(0.47,0.82,-0.33),0.35,"h",1,2);
gr->Sphere(mglPoint(0.33,0.57,-0.23),0.25,"g");
gr->Drop(mglPoint(0,0,0),mglPoint(0.47,-0.82,-0.33),0.35,"h",1,2);
gr->Sphere(mglPoint(0.33,-0.57,-0.23),0.25,"g");
gr->SubPlot(2,2,1);
gr->Text(mglPoint(0,1.2),"Water, H{_2}O",0,-3); gr->Rotate(60,100);
gr->Sphere(mglPoint(0,0,0),0.25,"r");
gr->Drop(mglPoint(0,0,0),mglPoint(0.3,0.5,0),0.3,"m",1,2);
gr->Sphere(mglPoint(0.3,0.5,0),0.25,"g");
gr->Drop(mglPoint(0,0,0),mglPoint(0.3,-0.5,0),0.3,"m",1,2);
gr->Sphere(mglPoint(0.3,-0.5,0),0.25,"g");
gr->SubPlot(2,2,2);
gr->Text(mglPoint(0,1.2),"Oxygen, O_2",0,-3); gr->Rotate(60,120);
gr->Drop(mglPoint(0,0.5,0),mglPoint(0,-0.3,0),0.3,"m",1,2);
gr->Sphere(mglPoint(0,0.5,0),0.25,"r");
gr->Drop(mglPoint(0,-0.5,0),mglPoint(0,0.3,0),0.3,"m",1,2);
gr->Sphere(mglPoint(0,-0.5,0),0.25,"r");
gr->SubPlot(2,2,3);
gr->Text(mglPoint(0,1.2),"Ammonia, NH_3",0,-3); gr->Rotate(60,120);
gr->Sphere(mglPoint(0,0,0),0.25,"b");
gr->Drop(mglPoint(0,0,0),mglPoint(0.33,0.57,0),0.32,"n",1,2);
gr->Sphere(mglPoint(0.33,0.57,0),0.25,"g");
gr->Drop(mglPoint(0,0,0),mglPoint(0.33,-0.57,0),0.32,"n",1,2);
gr->Sphere(mglPoint(0.33,-0.57,0),0.25,"g");
gr->Drop(mglPoint(0,0,0),mglPoint(-0.65,0,0),0.32,"n",1,2);
gr->Sphere(mglPoint(-0.65,0,0),0.25,"g");

MGL code

alpha on
light on
subplot 2 2 0
text 0 1.2 'Methane, CH_4' '' -3
rotate 60 120
sphere 0 0 0 0.25 'k'
drop 0 0 0 0 0 1 0.35 'h' 1 2
sphere 0 0 0.7 0.25 'g'
drop 0 0 0 -0.94 0 -0.33 0.35 'h' 1 2
sphere -0.66 0 -0.23 0.25 'g'
drop 0 0 0 0.47 0.82 -0.33 0.35 'h' 1 2
sphere 0.33 0.57 -0.23 0.25 'g'
drop 0 0 0 0.47 -0.82 -0.33 0.35 'h' 1 2
sphere 0.33 -0.57 -0.23 0.25 'g'
subplot 2 2 1
text 0 1.2 'Water, H{_2}O' '' -3
rotate 60 100
sphere 0 0 0 0.25 'r'
drop 0 0 0 0.3 0.5 0 0.3 'm' 1 2
sphere 0.3 0.5 0 0.25 'g'
drop 0 0 0 0.3 -0.5 0 0.3 'm' 1 2
sphere 0.3 -0.5 0 0.25 'g'
subplot 2 2 2
text 0 1.2 'Oxygen, O_2' '' -3
rotate 60 120
drop 0 0.5 0 0 -0.3 0 0.3 'm' 1 2
sphere 0 0.5 0 0.25 'r'
drop 0 -0.5 0 0 0.3 0 0.3 'm' 1 2
sphere 0 -0.5 0 0.25 'r'
subplot 2 2 3
text 0 1.2 0 'Ammonia, NH_3' '' -3
rotate 60 120
sphere 0 0 0 0.25 'b'
drop 0 0 0 0.33 0.57 0 0.32 'n' 1 2
sphere 0.33 0.57 0 0.25 'g'
drop 0 0 0 0.33 -0.57 0 0.32 'n' 1 2
sphere 0.33 -0.57 0 0.25 'g'
drop 0 0 0 -0.65 0 0 0.32 'n' 1 2
sphere -0.65 0 0 0.25 'g'

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.7 Advanced features


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.7.1 Curvelinear coorinates sample

png/sample3

C++ code

gr->Org = mglPoint(-1,1,-1);
gr->SubPlot(2,2,0); gr->Rotate(60,40);
gr->Line(mglPoint(-1,0.5,0),mglPoint(1,0.5,0),"r2",100);
gr->Axis(); gr->Grid();
gr->Text(mglPoint(0,1.3,1),"Cartesian");
gr->SubPlot(2,2,1); gr->Rotate(60,40);
gr->SetFunc("y*sin(pi*x)","y*cos(pi*x)");
gr->Line(mglPoint(-1,0.5,0),mglPoint(1,0.5,0),"r2",100);
gr->Axis(); gr->Grid();
gr->Text(mglPoint(0,1.3,1),"Cylindrical");
gr->SubPlot(2,2,2); gr->Rotate(60,40);
gr->SetFunc("2*y*x","y*y - x*x");
gr->Line(mglPoint(-1,0.5,0),mglPoint(1,0.5,0),"r2",100);
gr->Axis(); gr->Grid();
gr->Text(mglPoint(0,1.3,1),"Parabolic");
gr->SubPlot(2,2,3); gr->Rotate(60,40);
gr->SetFunc("y*sin(pi*x)","y*cos(pi*x)","x+z");
gr->Line(mglPoint(-1,0.5,0),mglPoint(1,0.5,0),"r2",100);
gr->Axis(); gr->Grid();
gr->Text(mglPoint(0,1.3,1),"Spiral");
gr->Axis(0,0,0); // set to default Cartesian

MGL code

origin -1 1 -1
subplot 2 2 0
rotate 60 40
line -1 0.5 0 1 0.5 0 'r2'
axis
grid
text 0 1.3 1 'Cartesian'
subplot 2 2 1
rotate 60 40
axis 'y*sin(pi*x)' 'y*cos(pi*x)' ''
line -1 0.5 0 1 0.5 0 'r2'
axis
grid
text 0 1.3 1 'Cylindrical'
subplot 2 2 2
rotate 60 40
axis '2*y*x' 'y*y - x*x' ''
line -1 0.5 0 1 0.5 0 'r2'
axis
grid
text 0 1.3 1 'Parabolic'
subplot 2 2 3
rotate 60 40
axis 'y*sin(pi*x)' 'y*cos(pi*x)' 'x+z'
line -1 0.5 0 1 0.5 0 'r2'
axis
grid
text 0 1.3 1 'Spiral'
axis '' '' '' # set to default Cartesian

Pure C code

mgl_set_origin(gr,-1,1,-1);
mgl_subplot(gr,2,2,0); mgl_rotate(gr,60,40,0);
mgl_line(gr,-1,0.5,0,1,0.5,0,"r2",100);
mgl_axis(gr,"xyz"); mgl_axis_grid(gr,"xyz","B");
mgl_text(gr,0,1.3,1,"Cartesian");
mgl_subplot(gr,2,2,1); mgl_rotate(gr,60,40,0);
mgl_set_func(gr,"y*sin(pi*x)","y*cos(pi*x)",0);
mgl_line(gr,-1,0.5,0,1,0.5,0,"r2",100);
mgl_axis(gr,"xyz"); mgl_axis_grid(gr,"xyz","B");
mgl_text(gr,0,1.3,1,"Cylindrical");
mgl_subplot(gr,2,2,2); mgl_rotate(gr,60,40,0);
mgl_set_func(gr,"2*y*x","y*y - x*x","");
mgl_line(gr,-1,0.5,0,1,0.5,0,"r2",100);
mgl_axis(gr,"xyz"); mgl_axis_grid(gr,"xyz","B");
mgl_text(gr,0,1.3,1,"Parabolic");
mgl_subplot(gr,2,2,3); mgl_rotate(gr,60,40,0);
mgl_set_func(gr,"y*sin(pi*x)","y*cos(pi*x)","x+z");
mgl_line(gr,-1,0.5,0,1,0.5,0,"r2",100);
mgl_axis(gr,"xyz"); mgl_axis_grid(gr,"xyz","B");
mgl_text(gr,0,1.3,1,"Spiral");
mgl_set_func(gr,0,0,0); /* set to default Cartesian */

Fortran code

call mgl_set_origin(gr,-1.,1.,-1.)
call mgl_subplot(gr,2,2,0)
call mgl_rotate(gr,60.,40.,0.)
call mgl_line(gr,-1.,0.5,0.,1.,0.5,0.,'r2',100)
call mgl_axis(gr,'xyz')
call mgl_axis_grid(gr,'xyz','B')
call mgl_text(gr,0.,1.3,1.,'Cartesian')
call mgl_subplot(gr,2,2,1)
call mgl_rotate(gr,60.,40.,0.)
call mgl_set_func(gr,'y*sin(pi*x)','y*cos(pi*x)','')
call mgl_line(gr,-1.,0.5,0.,1.,0.5,0.,'r2',100)
call mgl_axis(gr,'xyz')
call mgl_axis_grid(gr,'xyz','B')
call mgl_text(gr,0.,1.3,1.,'Cylindrical')
call mgl_subplot(gr,2,2,2)
call mgl_rotate(gr,60.,40.,0.)
call mgl_set_func(gr,'2*y*x','y*y - x*x','')
call mgl_line(gr,-1.,0.5,0.,1.,0.5,0.,'r2',100)
call mgl_axis(gr,'xyz')
call mgl_axis_grid(gr,'xyz','B')
call mgl_text(gr,0.,1.3,1.,"Parabolic")
call mgl_subplot(gr,2,2,3)
call mgl_rotate(gr,60.,40.,0.)
call mgl_set_func(gr,'y*sin(pi*x)','y*cos(pi*x)','x+z')
call mgl_line(gr,-1.,0.5,0.,1.,0.5,0.,'r2',100)
call mgl_axis(gr,'xyz')
call mgl_axis_grid(gr,'xyz','B')
call mgl_text(gr,0.,1.3,1.,'Spiral')
call mgl_set_func(gr,'','','') ! set to default Cartesian

Python

gr.SetOrigin(-1,1,-1);
gr.SubPlot(2,2,0);              gr.Rotate(60,40);
gr.Line(-1,0.5,0,1,0.5,0,"r2",100);
gr.Axis();              gr.Grid();
gr.Puts(0,1.3,1,"Gartesian","rC",-1.5);
gr.SubPlot(2,2,1);  gr.Rotate(60,40);
gr.SetFunc("y*sin(pi*x)","y*cos(pi*x)");
gr.Line(-1,0.5,0,1,0.5,0,"r2",100);
gr.Axis();          gr.Grid();
gr.Puts(0,1.3,1,"Cylindrical","rC",-1.5);
gr.SubPlot(2,2,2);  gr.Rotate(60,40);
gr.SetFunc("2*y*x","y*y-x*x");
gr.Line(-1,0.5,0,1,0.5,0,"r2",100);
gr.Axis();          gr.Grid();
gr.Puts(0,1.3,1,"Parabolic","rC",-1.5);
gr.SubPlot(2,2,3);  gr.Rotate(60,40);
gr.SetFunc("y*sin(pi*x)","y*cos(pi*x)","x+z");
gr.Line(-1,0.5,0,1,0.5,0,"r2",100);
gr.Axis();          gr.Grid();
gr.Puts(0,1.3,1,"Spiral","rC",-1.5);
gr.SetFunc("","");   # set to default Gartesian

[ < ] [ > ]   [ << ] [ 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");

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.7.3 Semi-log sample

png/semilog

C++ code

mglData x(2000), y(2000);
x.Modify("0.01/(x+10^(-5))"); y.Modify("sin(1/v)",x);
gr->Axis(mglPoint(0.01,-1),mglPoint(1000,1),mglPoint(0.01,-1));
gr->SetFunc("lg(x)",0);  gr->SetTicks('x',0);
gr->Box();
gr->Plot(x,y,"b2");
gr->Axis(); gr->Grid("xy","g");
gr->Label('x',"x",0);   gr->Label('y', "y = sin 1/x",0);

MGL code

new x 2000
new y 2000
modify x '0.01/(x+10^(-5))'
modify y 'sin(1/v)' x
xrange 0.01 1000
origin 0.01 -1 0
xtick 0
axis 'lg(x)' '' ''
plot x y 'b2'
axis
grid 'xy' 'g'
xlabel 'x' 0
ylabel 'y = sin 1/x' 0
box

Pure C code

HMDT x = mgl_create_data_size(2000,1,1);
HMDT y = mgl_create_data_size(2000,1,1);
mgl_data_modify(x,"0.01/(x+10^(-5))",0);
mgl_data_modify_vw(y,"sin(1/v)",x,0);
mgl_set_axis(gr,0.01,-1.,0.,1000.,1.,0.,0.01,-1.,0.);
mgl_set_func(gr,"lg(x)",0,0);
mgl_set_ticks(gr,0.,-5.,-5.);
mgl_box(gr,1);
mgl_plot_xy(gr,x,y,"b2");
mgl_axis(gr,"xy"); mgl_axis_grid(gr,"xy","g");
mgl_label_ext(gr,'x',"x",0,-1.4,0);
mgl_label_ext(gr,'y', "y = sin 1/x",0,-1.4,0);
mgl_delete_data(x); mgl_delete_data(y);

Fortran code

integer x,y, mgl_create_data_size
x = mgl_create_data_size(2000,1,1)
y = mgl_create_data_size(2000,1,1)
call mgl_data_modify(x,'0.01/(x+10^(-5))',0)
call mgl_data_modify_vw(y,'sin(1/v)',x,x)
call mgl_set_axis(gr,0.01,-1.,0.,1000.,1.,0.,0.01,-1.,0.)
call mgl_set_func(gr,'lg(x)','','')
call mgl_set_ticks(gr,0.,-5.,-5.)
call mgl_box(gr,1)
call mgl_plot_xy(gr,x,y,'b2')
call mgl_axis(gr,'xy')
call mgl_axis_grid(gr,'xy','g')
call mgl_label_ext(gr,'x','x',0.,-1.4,0.)
call mgl_label_ext(gr,'y', 'y = sin 1/x',0.,-1.4,0.)
call mgl_delete_data(x)
call mgl_delete_data(y)

Python

TO BE DONE

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.7.4 Log-log sample

png/loglog

C++ code

mglData x(100), y(100);
x.Modify("pow(10,6*x-3)"); y.Modify("sqrt(1+v^2)",x);
gr->Axis(mglPoint(0.001,0.1),mglPoint(1000,1000),mglPoint(0.001,0.1));
gr->SetFunc("lg(x)","lg(y)");
gr->SetTicks('x',0);    gr->SetTicks('y',0);
gr->Box();
gr->Plot(x,y,"b2");
gr->Axis(); gr->Grid("xy","g;");
gr->Label('x',"x",0); gr->Label('y', "y=\\sqrt{1+x^2}",0);

MGL code

new x 100
new y 100
modify x 'pow(10,6*x-3)'
modify y 'sqrt(1+v^2)' x
axis 0.001 0.1 1000 1000
xtick 0
ytick 0
axis 'lg(x)' 'lg(y)' ''
plot x y 'b2'
axis
grid 'xy' 'g;'
xlabel 'x' 0
ylabel 'y=\sqrt{1+x^2}' 0
box

Pure C code

HMDT x = mgl_create_data_size(100,1,1);
HMDT y = mgl_create_data_size(100,1,1);
mgl_data_modify(x,"pow(10,6*x-3)",0);
mgl_data_modify_vw(y,"sqrt(1+v^2)",x,0);
mgl_set_axis(gr,0.001,0.1,0.,1000.,1000.,0.,0.001,0.1,0.);
mgl_set_func(gr,"lg(x)","lg(y)",0);
mgl_set_ticks(gr,0.,0.,-5.);
mgl_box(gr,1);
mgl_plot_xy(gr,x,y,"b2");
mgl_axis(gr,"xy"); mgl_axis_grid(gr,"xy","g;");
mgl_label_ext(gr,'x',"x",0,-1.4,0);
mgl_label_ext(gr,'y', "y=\\sqrt{1+x^2}",0,-1.4,0);
mgl_delete_data(x); mgl_delete_data(y);

Fortran code

integer x,y, mgl_create_data_size
x = mgl_create_data_size(100,1,1)
y = mgl_create_data_size(100,1,1)
call mgl_data_modify(x,'pow(10,6*x-3)',0)
call mgl_data_modify_vw(y,'sqrt(1+v^2)',x,x)
call mgl_set_axis(gr,0.001,0.1,0.,1000.,1000.,0.,0.001,0.1,0.)
call mgl_set_func(gr,'lg(x)','lg(y)','')
call mgl_set_ticks(gr,0.,0.,-5.)
call mgl_box(gr,1)
call mgl_plot_xy(gr,x,y,'b2')
call mgl_axis(gr,'xy')
call mgl_axis_grid(gr,'xy','g;')
call mgl_label_ext(gr,'x','x',0.,-1.4,0)
call mgl_label_ext(gr,'y', 'y=\sqrt{1+x^2}',0.,-1.4,0)
call mgl_delete_data(x)
call mgl_delete_data(y)

Python

x, y = mglData(100), mglData(100);
x.Modify("pow(10,6*x-3)");          y.Modify("sqrt(1+v^2)",x);
gr.SetRanges(0.001,1000,0.1,1000);  gr.SetOrigin(0.001,0.1);
gr.SetFunc("lg(x)","lg(y)");
gr.SetTicks("x",0);     gr.SetTicks("y",0);
gr.Box();               gr.Plot(x,y,"b2");
gr.Axis();              gr.Grid("xy","g;");
gr.Label("x","x",0);    gr.Label("y","y=\\sqrt{1+x^2}",0);

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.7.5 Fitting sample

png/fit

C++ code

mglData rnd(100), in(100), res;
rnd.Fill("0.4*rnd+0.1+sin(2*pi*x)", gr->Min, gr->Max);
in.Fill("0.3+sin(2*pi*x)", gr->Min, gr->Max);
gr->Axis(mglPoint(-1,-2), mglPoint(1,2));
gr->Plot(rnd, ". ");
gr->Box();
float ini[3] = {1,1,3};
gr->Fit(res, rnd, "a+b*sin(c*x)", "abc", ini);
gr->Plot(res, "r");
gr->Plot(in, "b");
gr->Text(mglPoint(-1, -1.3), "fitted:", "L:r", -1);
gr->PutsFit(mglPoint(0, -1.8), "y = ", "C:r", -1);
gr->Text(mglPoint(0, 2.2), "initial: y = 0.3+sin(2\\pi x)", "C:b", -1);

MGL code

new rnd 100
fill rnd '0.4*rnd+0.1+sin(2*pi*x)'
new in 100
fill in '0.3+sin(2*pi*x)'
yrange -2 2
plot rnd '. '
box
list ini 1 1 3
fit res rnd 'a+b*sin(c*x)' 'abc' ini
plot res 'r'
plot in 'b'
text -1 -1.3 'fitted:' 'L:r' -1
putsfit 0 -1.8 'y = ' 'C:r'
text 0 2.2 'initial: y = 0.3+sin(2\pi x)' 'C:b' -1

Pure C code

HMDT rnd,in,res;
float ini[3] = {1,1,3};
rnd = mgl_create_data_size(100,1,1);
in = mgl_create_data_size(100,1,1);
res = mgl_create_data();
mgl_data_modify(rnd,"0.4*rnd+0.1+sin(4*pi*x)",0);
mgl_data_modify(in,"0.3+sin(4*pi*x)",0);
mgl_set_axis_2d(gr,-1.,-2.,1.,2.);
mgl_plot(gr,rnd,". ");
mgl_box(gr,1);
mgl_fit_1(gr,res,rnd,"a+b*sin(c*x)","abc",ini);
mgl_plot(gr,res,"r");   mgl_plot(gr,in,"b");
mgl_puts_ext(gr,-1.,-1.3,0.,"fitted:","L:r",-1.,'t');
mgl_puts_fit(gr,0.,-1.8,0.,"y = ","C:r",-1.);
mgl_puts_ext(gr,0.,2.2,0.,"initial: y = 0.3+sin(2\\pi x)","C:b", -1., 't');

Fortran code

integer rnd,in,res, mgl_create_data_size
real ini(3)
ini(1)=1;   ini(2)=1;   ini(3)=3;
rnd = mgl_create_data_size(100,1,1);
in = mgl_create_data_size(100,1,1);
res = mgl_create_data();
call mgl_data_modify(rnd,"0.4*rnd+0.1+sin(4*pi*x)",0);
call mgl_data_modify(in,"0.3+sin(4*pi*x)",0);
call mgl_set_axis_2d(gr,-1.,-2.,1.,2.);
call mgl_plot(gr,rnd,". ");
call mgl_box(gr,1);
call mgl_fit_1(gr,res,rnd,"a+b*sin(c*x)","abc",ini);
call mgl_plot(gr,res,"r");
call mgl_plot(gr,in,"b");
call mgl_puts_ext(gr,-1.,-1.3,0.,"fitted:","L:r",-1.,'t');
call mgl_puts_fit(gr,0.,-1.8,0.,"y = ","C:r",-1.);
call mgl_puts_ext(gr,0.,2.2,0.,"initial: y = 0.3+sin(2\\pi x)","C:b", -1., 't');

Python

rnd, In, res, ini = mglData(100), mglData(100), mglData(), mglData(3);
rnd.Modify("0.4*rnd+0.1+sin(4*pi*x)");
In.Modify("0.3+sin(4*pi*x)");
gr.SetRanges(-1,1,-2,2);
gr.Plot(rnd,". ");
gr.Box();
ini[0], ini[1], ini[2] = 1, 1, 3;
gr.Fit(res,rnd,"a+b*sin(c*x)","abc",ini);
gr.Plot(res,"r");   gr.Plot(In,"b");
gr.Puts(-1,-1.3,0,"fitted:","L:r",-1);
gr.PutsFit(0,-1.8,0,"y = ","C:r",-1);
gr.Puts(0,2.2,0,"initial: y = 0.3+sin(2\\pi x)","C:b",-1);

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.7.6 Envelop sample

png/envelop

C++ code

mglData a(1000);
a.Fill("exp(-8*x^2)*sin(10*pi*x)", gr->Min, gr->Max);
gr->Plot(a, "b");
a.Envelop('x');
gr->Plot(a, "r");
gr->Axis();

MGL code

new a 1000
fill a 'exp(-8*x^2)*sin(10*pi*x)'
plot a 'b'
envelop a
plot a 'r'
axis

Pure C code

HMDT a = mgl_create_data_size(1000,1,1);
mgl_data_fill_eq(gr,a, "exp(-8*x^2)*sin(10*pi*x)", 0,0);
mgl_plot(gr,a,"b");
mgl_data_envelop(a,'x');
mgl_plot(gr,a,"r");
mgl_axis(gr,"xyz");

Fortran code

integer a, mgl_create_data_size
a = mgl_create_data_size(1000,1,1)
call mgl_data_fill_eq(gr,a, 'exp(-8*x^2)*sin(10*pi*x)', 0,0)
call mgl_plot(gr,a,'b')
call mgl_data_envelop(a,'x')
call mgl_plot(gr,a,'r')
call mgl_axis(gr,'xyz')

Python

a = mglData(1000);
gr.Fill(a, "exp(-8*x^2)*sin(10*pi*x)");
gr.Plot(a,"b");
a.Envelop("x");
gr.Plot(a,"r");
gr.Axis();

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.7.7 Sew sample

png/sew

C++ code

mglData a(100, 100);
a.Modify("mod((y^2-(1-x)^2)/2,0.1)");
gr->Rotate(40, 60);
gr->Light(true);
gr->Alpha(true);
gr->Surf(a, "b");
a.Sew("xy", 0.1);
gr->Surf(a, "r");
gr->Box();

MGL code

new a 100 100
modify a 'mod((y^2-(1-x)^2)/2,0.1)'
rotate 40 60
light on
alpha on
surf a 'b'
sew a 'xy' 0.1
surf a 'r'
box

Pure C code

HMDT a = mgl_create_data_size(100,100,1);
mgl_data_modify(a, "mod((y^2-(1-x)^2)/2, 0.1)", 0);
mgl_rotate(gr,40.,60.,0.);
mgl_set_light(gr,1);
mgl_set_alpha(gr,1);
mgl_surf(gr,a,"b");
mgl_data_sew(a,"xy",0.1);
mgl_surf(gr,a,"r");
mgl_box(gr,1);

Fortran code

integer a, mgl_create_data_size
a = mgl_create_data_size(100,100,1)
call mgl_data_modify(a, 'mod((y^2-(1-x)^2)/2, 0.1)', 0)
call mgl_rotate(gr,40.,60.,0.)
call mgl_set_light(gr,1)
call mgl_set_alpha(gr,1)
call mgl_surf(gr,a,'b')
call mgl_data_sew(a,'xy',0.1)
call mgl_surf(gr,a,'r')
call mgl_box(gr,1)

Python

a = mglData(100, 100);
a.Modify("mod((y^2-(1-x)^2)/2, 0.1)");
gr.Rotate(40, 60);  gr.Light(True);     gr.Alpha(True);
gr.Surf(a, "b");
a.Sew("xy", 0.1);
gr.Surf(a, "r");
gr.Box();

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.7.8 STFA sample

png/stfa

C++ code

mglData a(2000), b(2000);
a.Fill("cos(50*pi*x)*(x<-.5)+cos(100*pi*x)*(x<0)*(x>-.5)+ \
        cos(200*pi*x)*(x<.5)*(x>0)+cos(400*pi*x)*(x>.5)", 
        gr->Min, gr->Max);
gr->SubPlot(1, 2, 0);
gr->Plot(a);
gr->Axis();
gr->Label('x', "\\i t");
gr->SubPlot(1, 2, 1);
gr->STFA(a, b, 64);
gr->Axis();
gr->Label('x', "\\i t");
gr->Label('y', "\\omega", 0);

MGL code

new a 2000
new b 2000
fill a 'cos(50*pi*x)*(x<-.5)+cos(100*pi*x)*(x<0)*(x>-.5)+
        cos(200*pi*x)*(x<.5)*(x>0)+cos(400*pi*x)*(x>.5)'
subplot 1 2 0
plot a
axis
xlabel '\i t'
subplot 1 2 1
stfa a b 64 ''
axis
ylabel '\omega' 0
xlabel '\i t'

Pure C code

HMDT a = mgl_create_data_size(2000,1,1);
HMDT b = mgl_create_data_size(2000,1,1);
mgl_data_fill_eq(gr, a, "cos(50*pi*x)*(x<-.5)+cos(100*pi*x)*(x<0)*(x>-.5)+ \
        cos(200*pi*x)*(x<.5)*(x>0)+cos(400*pi*x)*(x>.5)",0,0);
mgl_subplot(gr,1,2,0);
mgl_plot(gr,a,"");
mgl_axis(gr,"xy");
mgl_label(gr,'x', "\\i t");
mgl_subplot(gr,1,2,1);
mgl_stfa(gr,a,b,64,"",0.);
mgl_axis(gr,"xy");
mgl_label(gr,'x', "\\i t");
mgl_label(gr,'y', "\\omega");

Fortran code

integer a,b, mgl_create_data_size
a = mgl_create_data_size(2000,1,1)
b = mgl_create_data_size(2000,1,1)
call mgl_data_fill_eq(gr, a, 'cos(50*pi*x)*(x<-.5)+cos(100*pi*x)*(x<0)*(x>-.5)+ &
        cos(200*pi*x)*(x<.5)*(x>0)+cos(400*pi*x)*(x>.5)',0,0)
call mgl_subplot(gr,1,2,0)
call mgl_plot(gr,a,'')
call mgl_axis(gr,'xy')
call mgl_label(gr,'x', '\i t')
call mgl_subplot(gr,1,2,1)
call mgl_stfa(gr,a,b,64,'',0.)
call mgl_axis(gr,'xy')
call mgl_label(gr,'x', '\i t')
call mgl_label(gr,'y', '\omega')

Python

a, b = mglData(2000), mglData(2000);
gr.Fill(a,"cos(50*pi*x)*(x<-.5)+cos(100*pi*x)*(x<0)*(x>-.5)+ \
        cos(200*pi*x)*(x<.5)*(x>0)+cos(400*pi*x)*(x>.5)");
gr.SubPlot(1, 2, 0);
gr.Plot(a);
gr.Axis();
gr.Label('x', "\\i t");
gr.SubPlot(1, 2, 1);
gr.STFA(a, b, 64);
gr.Axis();
gr.Label('x', "\\i t");
gr.Label('y', "\\omega", 0);

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.7.9 PDE sample

png/pde

C++ code

mglData a,re(128),im(128);
gr->Axis();
gr->Label('x', "\\i x");
gr->Label('y', "\\i z");
	
re.Fill("exp(-48*(x+0.7)^2)", gr->Min, gr->Max);
a = mglPDE("p^2+q^2-x-1+i*0.5*(z+x)*(z>-x)", re, im, gr->Min, gr->Max, 0.01, 30);
a.Transpose("yxz");
gr->CAxis(0, 1);
gr->Dens(a,"wyrRk");
gr->Plot("-x", "k|");
gr->Puts(mglPoint(0, 0.85), "absorption: (x+z)/2 for x+z>0");
gr->Title("\\r{Equation:} ik_0\\partial_zu + \\Delta u + x\\cdot u + \
i \\frac{x+z}{2}\\cdot u = 0", "iC", -1.5);

MGL code

axis
xlabel '\i x'
ylabel '\i z'
new re 128
new im 128
fill re 'exp(-48*(x+0.7)^2)'
pde a 'p^2+q^2-x-1+i*0.5*(z+x)*(z>-x)' re im 0.01 30
transpose a
crange 0 1
dens a 'wyrRk'
fplot '-x' 'k|'
text 0 0.85 'absorption: (x+z)/2 for x+z>0' '' -1
title 'Equation: ik_0\partial_zu + \Delta u + x\cdot u + i \frac{x+z}{2}\cdot u = 0' 'iC' -1.5

Pure C code

HMDT a = mgl_create_data();
HMDT re = mgl_create_data_size(128,1,1);
HMDT im = mgl_create_data_size(128,1,1);
mgl_axis(gr,"xyz");
mgl_label(gr,'x', "\\i x");
mgl_label(gr,'y', "\\i z");
mgl_data_fill_eq(gr,re,"exp(-48*(x+0.7)^2)", 0, 0);
a = mgl_pde_solve(gr, "p^2+q^2-x-1+i*0.5*(z+x)*(z>-x)", re, im, 0.01, 30.);
mgl_data_transpose(a, "yxz");
mgl_set_caxis(gr, 0, 1);
mgl_dens(gr, a,"wyrRk", -1.);
mgl_fplot(gr, "-x", "k|", 100);
mgl_puts(gr, 0., 0.85, 0., "absorption: (x+z)/2 for x+z>0");
mgl_title(gr, "\\r{Equation:} ik_0\\partial_zu + \\Delta u + x\\cdot u + \
i \\frac{x+z}{2}\\cdot u = 0", "iC", -1.5);
mgl_delete_data(a);
mgl_delete_data(im);
mgl_delete_data(re);

Fortran code

integer a,re,im, mgl_create_data_size
a = mgl_create_data()
re = mgl_create_data_size(128,1,1)
im = mgl_create_data_size(128,1,1)
call mgl_axis(gr,'xyz')
call mgl_label(gr,'x', '\i x')
call mgl_label(gr,'y', '\i z')
call mgl_data_fill_eq(gr,re,'exp(-48*(x+0.7)^2)', 0, 0)
a = mgl_pde_solve(gr, 'p^2+q^2-x-1+i*0.5*(z+x)*(z>-x)', re, im, 0.01, 30.)
call mgl_data_transpose(a, 'yxz')
call mgl_set_caxis(gr, 0., 1.)
call mgl_dens(gr, a,'wyrRk', -1.)
call mgl_fplot(gr, '-x', 'k|', 100)
call mgl_puts(gr, 0., 0.85, 0., 'absorption: (x+z)/2 for x+z>0')
call mgl_title(gr, '\r{Equation:} ik_0\partial_zu + \Delta u + x\cdot u + &
i \frac{x+z}{2}\cdot u = 0', 'iC', -1.5)
call mgl_delete_data(a)
call mgl_delete_data(im)
call mgl_delete_data(re)

Python

a, re, im = mglData(), mglData(128), mglData(128);
gr.Axis();
gr.Label('x', "\\i x");
gr.Label('y', "\\i z");
	
gr.Fill(re,"exp(-48*(x+0.7)^2)");
a = gr.PDE("p^2+q^2-x-1+i*0.5*(z+x)*(z>-x)", re, im, 0.01, 30);
a.Transpose("yxz");
gr.SetCRange(0, 1);
gr.Dens(a,"wyrRk");
gr.Plot("-x", "k|");
gr.Puts(0, 0.85, 0., "absorption: (x+z)/2 for x+z>0");
gr.Title("\\r{Equation:} ik_0\\partial_zu + \\Delta u + x\\cdot u + \
i \\frac{x+z}{2}\\cdot u = 0", "iC", -1.5);

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.7.10 Beam tracing sample

png/qo2d

C++ code

mglData r, xx, yy, a, im(128), re(128);
const char *ham = "p^2+q^2-x-1+i*0.5*(y+x)*(y>-x)";
r = mglRay(ham, mglPoint(-0.7, -1), mglPoint(0, 0.5), 0.02, 2);
gr->Plot(r.SubData(0), r.SubData(1), "k");
gr->Axis();	gr->Label('x', "\\i x");	gr->Label('y', "\\i z");
// now start beam tracing
re.Fill("exp(-48*x^2)", gr->Min, gr->Max);
a = mglQO2d(ham, re, im, r, 1, 30, &xx, &yy);
gr->CAxis(0, 1);
gr->Dens(xx, yy, a, "wyrRk");
gr->Plot("-x", "k|");
gr->Puts(mglPoint(0, 0.85), "absorption: (x+y)/2 for x+y>0");
gr->Puts(mglPoint(0.7, -0.05), "central ray");
gr->Title("Beam and ray tracing", "C", -1.5);

MGL code

define $1 'p^2+q^2-x-1+i*0.5*(y+x)*(y>-x)'
ray r $1 -0.7 -1 0 0 0.5 0 0.02 2
plot r(0) r(1) 'k'
axis
xlabel '\i x'
ylabel '\i z'
new re 128
new im 128
new xx
new yy
fill re 'exp(-48*x^2)'
qo2d a $1 re im r 1 30 xx yy 
crange 0 1
dens xx yy a 'wyrRk'
fplot '-x' 'k|'
text -0.8 0.85 'absorption: (x+y)/2 for x+y>0' 'L' -1
text 0.5 -0.05 'central ray' 'L' -1
title 'Beam and ray tracing' 'C' -1.5

Pure C code

const char *ham = "p^2+q^2-x-1+i*0.5*(y+x)*(y>-x)";
HMDT r, xx, yy, a, im, re;
im = mgl_create_data_size(128,1,1);
re = mgl_create_data_size(128,1,1);
r = mgl_ray_trace(ham, -0.7, -1., 0., 0., 0.5, 0., 0.02, 2.);
xx = mgl_data_subdata(r,0,-1,-1);
yy = mgl_data_subdata(r,1,-1,-1);
mgl_plot_xy(gr, xx, yy, "k");
mgl_axis(gr,"xyz");
mgl_label(gr,'x',"\\i x");
mgl_label(gr,'y',"\\i z");
mgl_data_fill_eq(gr,re,"exp(-48*x^2)", 0, 0);
a = mgl_qo2d_solve(ham, re, im, r, 1, 30, xx, yy);
mgl_set_caxis(gr,0.,1.);
mgl_dens_xy(gr,xx, yy, a, "wyrRk", -1.);
mgl_fplot(gr,"-x", "k|",100);
mgl_puts(gr, 0., 0.85, 0., "absorption: (x+y)/2 for x+y>0");
mgl_puts(gr, 0.7, -0.05, 0., "central ray");
mgl_title(gr, "Beam and ray tracing", "C", -1.5);
mgl_delete_data(a);     mgl_delete_data(r);
mgl_delete_data(xx);    mgl_delete_data(yy);
mgl_delete_data(im);    mgl_delete_data(re);

Fortran code

integer r, xx, yy, a, im, re, mgl_create_data_size
integer mgl_data_subdata, mgl_ray_trace, mgl_qo2d_solve
character*64 ham
ham = 'p^2+q^2-x-1+i*0.5*(y+x)*(y>-x)'
im = mgl_create_data_size(128,1,1)
re = mgl_create_data_size(128,1,1)
r = mgl_ray_trace(ham, -0.7, -1., 0., 0., 0.5, 0., 0.02, 2.)
xx = mgl_data_subdata(r,0,-1,-1)
yy = mgl_data_subdata(r,1,-1,-1)
call mgl_plot_xy(gr, xx, yy, 'k')
call mgl_axis(gr,'xyz')
call mgl_label(gr,'x','\i x')
call mgl_label(gr,'y','\i z')
call mgl_data_fill_eq(gr,re,'exp(-48*x^2)', 0, 0)
a = mgl_qo2d_solve(ham, re, im, r, 1., 30., xx, yy)
call mgl_set_caxis(gr,0.,1.)
call mgl_dens_xy(gr,xx, yy, a, 'wyrRk', -1.)
call mgl_fplot(gr,'-x', 'k|',100)
call mgl_puts(gr, 0., 0.85, 0., 'absorption: (x+y)/2 for x+y>0')
call mgl_puts(gr, 0.7, -0.05, 0., 'central ray')
call mgl_title(gr, 'Beam and ray tracing', 'C', -1.5)
call mgl_delete_data(a)
call mgl_delete_data(r)
call mgl_delete_data(xx)
call mgl_delete_data(yy)
call mgl_delete_data(im)
call mgl_delete_data(re)

Python

ham = "p^2+q^2-x-1+i*0.5*(y+x)*(y>-x)";
r, xx, yy, a = mglData(), mglData(), mglData(), mglData();
im, re = mglData(128), mglData(128);
r = mglRay(ham, mglPoint(-0.7, -1), mglPoint(0, 0.5), 0.02, 2);
gr.Plot(r.SubData(0), r.SubData(1), "k");
gr.Axis();	gr.Label('x', "\\i x");	gr.Label('y', "\\i z");
gr.Fill(re,"exp(-48*x^2)");
a = mglQO2d(ham, re, im, r, 1, 30, xx, yy);
gr.SetCRange(0, 1);
gr.Dens(xx, yy, a, "wyrRk");
gr.Plot("-x", "k|");
gr.Puts(0, 0.85, 0, "absorption: (x+y)/2 for x+y>0");
gr.Puts(0.7, -0.05, 0, "central ray");
gr.Title("Beam and ray tracing", "C", -1.5);

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.7.11 Parser sample

png/parser

C++ code

float a[100];   // let a_i = sin(4*pi*x), x=0...1
for(int i=0;i<100;i++) a[i]=sin(4*M_PI*i/99);
mglParse *parser = new mglParse;
mglData &d = (parser->AddVar("dat"))->d;
d.Set(a,100);   // set data to variable
parser->Execute(gr, "plot dat; xrange 0 1\nbox\naxis");
// you may break script at any line do something
// and continue after that
parser->Execute(gr, "xlabel 'x'\nylabel 'y'\nbox");
// also you may use cycles or conditions in script
parser->Execute(gr, "for $0 -1 1 0.1\nline 0 0 -1 $0 'r'\nnext");

MGL code

NOT AVAILABLE

Pure C code

float a[100];   /* let a_i = sin(4*pi*x), x=0...1 */
int i;
for(i=0;i<100;i++)  a[i]=sin(4*M_PI*i/99);
HMPR parser = mgl_create_parser();
HMDT d = mgl_add_var(parser, "dat");
mgl_data_set_float(d,a,100,1,1);    /* set data to variable */
mgl_parse_text(gr, parser, "plot dat; xrange 0 1\nbox\naxis");
/* you may break script at any line do something 
   and continue after that */
mgl_parse_text(gr, parser, "xlabel 'x'\nylabel 'y'");
/* also you may use cycles or conditions in script */
mgl_parse_text(gr, parser, "for $0 -1 1 0.1\nline 0 0 -1 $0 'r'\nnext");

Fortran code

integer i,parser,d, mgl_create_data_size, mgl_create_parser
real a(100)
! let a_i = sin(4*pi*x), x=0...1
do i = 1,100
    a(i)=sin(4*3.1415926*(i-1)/99)
end do
parser = mgl_create_parser()
d = mgl_add_var(parser, "dat")
call mgl_data_set_real(d,a,100,1,1)    ! set data to variable
! I don't know how put new line ('\n') into fortran string
! So call mgl_parse_text() for each string :(
call mgl_parse_text(gr, parser, "plot dat; xrange 0 1")
call mgl_parse_text(gr, parser, "box")
call mgl_parse_text(gr, parser, "axis")
! you may break script at any line do something 
! and continue after that
call mgl_parse_text(gr, parser, "xlabel 'x'")
call mgl_parse_text(gr, parser, "ylabel 'y'")
! there is now conditions because I don't know 
! how to send several string into parser at once :(
!! also you may use cycles or conditions in script
!call mgl_parse_text(gr, parser, "for $0 -1 1 0.1\nline 0 0 -1 $0 'r'\nnext")

Python You may need to use from numpy import * for defining functions like sin().

parser = mglParse();
dat = parser.AddVar("dat");
dat.Create(100);
for i in range(100):
  dat[i] = sin(4*pi*i/99);
parser.Execute(gr, "plot dat; xrange 0 1\nbox\naxis");
# you may break script at any line do something 
# and continue after that
parser.Execute(gr, "xlabel 'x'\nylabel 'y'");
# also you may use cycles or conditions in script
parser.Execute(gr, "for $0 -1 1 0.1\nline 0 0 -1 $0 'r'\nnext");

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.7.12 Tick values sample

png/tval

C++ code

gr->Axis(mglPoint(-M_PI, 0), mglPoint(M_PI, 2));
gr->SetTicksVal('x', 6, -M_PI, "-\\pi", -M_PI/2, "-\\pi/2", 0., "0", 
                0.886, "x^*", M_PI/2, "\\pi/2", M_PI, "\\pi");
gr->Axis();     gr->Grid();
gr->Plot("2*cos(x^2)^2", "r2", NAN, 300);

MGL code

axis -pi 0 pi 2
xtick -pi '-\pi' -1.571 '-\pi/2' 0 '0' 0.886 'x^*' 1.571 '\pi/2' pi '\pi'
axis 
grid
fplot '2*cos(x^2)^2' 'r2' nan 300

Pure C code

mgl_set_axis_2d(gr, -M_PI, 0, M_PI, 2);
mgl_set_ticks_val(gr, 'x', 6, -M_PI, "-\\pi", -M_PI/2, "-\\pi/2",
            0., "0", 0.886, "x^*", M_PI/2, "\\pi/2", M_PI, "\\pi");
mgl_axis(gr,"xyz");
mgl_axis_grid(gr,"xyz", "B-");
mgl_fplot(gr, "2*cos(x^2)^2", "r2", 300);

Fortran code

NOT AVAILABLE

Python

gr.SetRanges(-pi, pi, 0, 2);
parser = mglParse();
# very "stupid" way because SWIG not support variable arguments
parser.Execute(gr, "xtick -pi '-\pi' -1.571 '-\pi/2' 0 '0' "
                    "0.886 'x^*' 1.571 '\pi/2' pi '\pi'");
gr.Axis();     gr.Grid();
gr.Plot("2*cos(x^2)^2", "r2", 300);

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.7.13 ColumnPlot sample

png/column

C++ code

char str[32];
for(int i=0;i<4;i++)
{
        gr->ColumnPlot(4,i);
        gr->Box();
        sprintf(str,"Plot %d of 4",i);
        gr->Text(mglPoint(-0.5,0.5),str);
        sprintf(str,"sin(pi*x+pi*%d/2)",i);
        gr->Plot(str);
}

MGL code

for $1 0 3
columnplot 4 $1
box
text -0.5 0.5 'Plot $1 of 4'
fplot 'sin(pi*x+pi*$1/2)'
next

Pure C code

int i;
char str[32];
for(i=0;i<4;i++)
{
        mgl_columnplot(gr,4,i);
        mgl_box(gr,1);
        sprintf(str,"Plot %d of 4",i);
        mgl_text(gr,-0.5,0.5,0.,str);
        sprintf(str,"sin(pi*x+pi*%d/2)",i);
        mgl_fplot(gr,str,"",100);
}

Fortran code

NOT AVAILABLE

Python

NOT AVAILABLE

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.7.14 StickPlot sample

png/stick

C++ code

gr->SetRanges(-1, 1, -1, 1, 0, 1);  gr->Light(true);
gr->StickPlot(3, 0, 40, 30);        gr->Axis("xyz_");
gr->Surf("exp(-10*y^2-6*x^2)");
gr->Text(mglPoint(0.2, 0, 1.2), "z=0", "", -2);
gr->StickPlot(3, 1, 40, 30);        gr->Axis("xyz_");
gr->Surf("exp(-10*y^2/2-6*x^2)/sqrt(2)");
gr->Text(mglPoint(0.2, 0, 1.2), "z=1", "", -2);
gr->StickPlot(3, 2, 40, 30);        gr->Axis("xyz_");
gr->Surf("exp(-10*y^2/5-6*x^2)/sqrt(5)");
gr->Text(mglPoint(0.2, 0, 1.2), "z=2", "", -2);
gr->Label('x',"\\tau", 0);  gr->Label('y', "\\rho");

MGL code

ranges -1 1 -1 1 0 1:light on
stickplot 3 0 40 30 : axis 'xyz_'
fsurf 'exp(-10*y^2-6*x^2)'
text 0.2 0 1.2 'z=0' '' -2
stickplot 3 1 40 30 : axis 'xy_'
fsurf 'exp(-10*y^2/2-6*x^2)/sqrt(2)'
text 0.2 0 1.2 'z=1' '' -2
stickplot 3 2 40 30 : axis 'xy_'
fsurf 'exp(-10*y^2/5-6*x^2)/sqrt(5)'
text 0.2 0 1.2 'z=2' '' -2
xlabel '\tau' 0 : ylabel '\rho'

Pure C code

mgl_set_axis_3d(gr, -1, -1, 0, 1, 1, 1);
mgl_set_light(gr, 1);
mgl_stickplot(gr, 3, 0, 40, 30);
mgl_axis(gr, "xyz_");
mgl_fsurf(gr,"exp(-10*y^2-6*x^2)","",100);
mgl_text(gr, 0.2, 0, 1.2, "z=0");
mgl_stickplot(gr, 3, 1, 40, 30);
mgl_axis(gr, "xyz_");
mgl_fsurf(gr,"exp(-10*y^2/2-6*x^2)/sqrt(2)","",100);
mgl_text(gr, 0.2, 0, 1.2, "z=1");
mgl_stickplot(gr, 3, 2, 40, 30);
mgl_axis(gr, "xyz_");
mgl_fsurf(gr,"exp(-10*y^2/5-6*x^2)/sqrt(5)","",100);
mgl_text(gr, 0.2, 0, 1.2, "z=2");
mgl_label(gr,'x',"\\tau");
mgl_label(gr,'y', "\\rho");

Fortran code

NOT AVAILABLE

Python

gr->SetRanges(-1, 1, -1, 1, 0, 1);  gr->Light(true);
gr->StickPlot(3, 0, 40, 30);        gr->Axis("xyz_");
gr->Surf("exp(-10*y^2-6*x^2)");
gr->Text(mglPoint(0.2, 0, 1.2), "z=0", "", -2);
gr->StickPlot(3, 1, 40, 30);        gr->Axis("xyz_");
gr->Surf("exp(-10*y^2/2-6*x^2)/sqrt(2)");
gr->Text(mglPoint(0.2, 0, 1.2), "z=1", "", -2);
gr->StickPlot(3, 2, 40, 30);        gr->Axis("xyz_");
gr->Surf("exp(-10*y^2/5-6*x^2)/sqrt(5)");
gr->Text(mglPoint(0.2, 0, 1.2), "z=2", "", -2);
gr->Label('x',"\\tau", 0);  gr->Label('y', "\\rho");

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.7.15 Stereo image sample

png/stereo

C++ code

mglData a(50,40);
a.Modify("0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))");
gr->Light(true);
gr->SubPlot(2,1,0);
gr->Rotate(40,60+3);
gr->Box();   gr->Surf(a);
gr->SubPlot(2,1,1);
gr->Rotate(40,60-3);
gr->Box();   gr->Surf(a);

MGL code

new a 50 40
modify a '0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))'
light on
subplot 2 1 0
rotate 40 60+3
box:surf a
subplot 2 1 1
rotate 40 60-3
box:surf a

Pure C code

HMDT a = mgl_create_data_size(50,40,1);
mgl_data_modify(a,"0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))",0);
mgl_set_light(gr,1);
mgl_subplot(gr,2,1,0);
mgl_rotate(gr,40.,60.+3.,0.);
mgl_box(gr,1);
mgl_surf(gr,a,0);
mgl_subplot(gr,2,1,1);
mgl_rotate(gr,40.,60.-3.,0.);
mgl_box(gr,1);
mgl_surf(gr,a,0);
mgl_delete_data(a);

Fortran code

integer a, mgl_create_data_size
a = mgl_create_data_size(50,40,1);
call mgl_data_modify(a,"0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))",0);
call mgl_set_light(gr,1)
call mgl_subplot(gr,2,1,0)
call mgl_rotate(gr,40.,60.+3.,0.)
call mgl_box(gr,1)
call mgl_surf(gr,a,'')
call mgl_subplot(gr,2,1,1)
call mgl_rotate(gr,40.,60.-3.,0.)
call mgl_box(gr,1)
call mgl_surf(gr,a,'')
call mgl_delete_data(a)

Python

a = mglData(50,40);
a.Modify("0.6*sin(2*pi*x)*sin(3*pi*y)+0.4*cos(3*pi*(x*y))");
gr.Light(True);
gr.SubPlot(2,1,0);
gr.Rotate(40,60+3);
gr.Surf(a);  gr.Box();
gr.SubPlot(2,1,1);
gr.Rotate(40,60-3);
gr.Surf(a);  gr.Box();

[ << ] [ >> ]           [Top] [Contents] [Index] [ ? ]

This document was generated by Alexey Balakin on May 2, 2013 using texi2html 1.82.