MathGL – library for scientific graphics


Main

News

Features

Pictures

FAQ

MGL scripts

Download

Documentation

Contact

Other projects

SourceForge.net Logo thefreecountry.com: Free Programmers' Resources, Free Webmasters' Resources, Free Security Resources, Free Software Support This Project

The minimal code to view the examples for different languages [C++ / MGL / C / Fortran / Python] 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();