[ < ] | [ > ] | [ << ] | [ 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();
9.1 1D plotting samples | ||
9.2 2D plotting samples | ||
9.3 3D plotting samples | ||
9.4 Dual plotting samples | ||
9.5 Basic features | ||
9.6 Additional features | ||
9.7 Advanced features |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |