MathGL – library for scientific graphics


Main

News

Features

MGL scripts

Pictures

FAQ

Download

Documentation

Contact

Other projects

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

Frequently Asked Questions about MathGL

  • The plot does not appear
    Check that points of plot lie inside the bounding box or resize the bounding box by Axis() function. Check that the data have correct dimensions for selected type of plot. Be sure that the Finish() is called after plotting functions (or be sure that plot is saved to file). Check that it is not light reflection (especially for plots with flat faces, like Dens() or Tile()).
  • Can not find some special kind of plot
    Most of "new" type of plots can be created by using of the existing drawing functions. For example, the surface of curve rotation can be created by special function Torus() or as parametrically specified surface Surf(). If you can not find some type of plot then e-mail me and this plot will appear in the next version of MathGL library.
  • Should I know some graphical libraries (like OpenGL) for the using of MathGL library?
    No. The MathGL library is self-consistent and does not require the knowledge of exeternal libraries. The exception is the using of specific features of those libraries. For example, when you create your own window interface.
  • In which language the library is written? For which languages the library have interface?
    The core of MathGL library is written on C++. But there are interfaces for pure C, Fortran, Pascal, Forth languages and its own command language MGL. Note, the most of languages can use (can link) pure C functions. MathGL v.1.8 and later support a set of languages via SWIG library. Now 2 of them (Python and Octave) are included in build system. E-mail me if you need more languages.
  • I have class Foo and drawing method Foo::draw(mgGraph *gr). How I can use it in FLTK or GLUT window?
    The member-functions of classes have hidden parameter (the pointer to a class instance) in C++. So that its direct usage is impossible. The solution is writting interface function:
    int foo_draw(mglGraph *gr, void *par)
    { ((Foo *)foo)->draw(gr); }

    and using it in the call of Window() function:
    gr->Window(argc,argv,foo_draw,"Title",this);

    Also you can inherit yours class from mglDraw class and use functions like gr->Window(argc, argv, foo, "Title");. This method works for MathGL v.1.8 and later.
  • How can I print in Russia/Spanish/Arabian/Japanese and so on?
    The standart way is using UTF encoding for text output. But MathGL library also have interface for 8-bit (char *) strings with internal convertion to UTF. This conversion depend on current locale of yours OS. You may change it by setlocale() function. For example, for Russian text in CP1251 encoding you may use setlocale(LC_CTYPE, "ru_RU.cp1251") (under MS Windows the name of locale may differ – setlocale(LC_CTYPE, "russian_russia.1251")).
    I strongly recomend not to use the constant LC_ALL in conversion. Because it also change the number format that may lead to mistakes in formulas, and for writting and reading textual data files. For example, the program will await a ',' as decimal point but user will enter '.'.
  • How can I exclude from drawing a point or a region of plot?
    There are 3 general ways. First, the point with NAN value of one of coordinate will never be plotted. Second, special variables CutMin, CutMax and textual function CutOff() define the condition when the points should be ommited. Last, you may change the transparency of part of plot by help of functions SurfA(), Surf3A(). In last case the transparency is switched on smoothly.
  • How is the performance of MathGL to plot data in near real time?
    The plotting is rather fast – see table for drawing time for different kind of plots. There are 2 ways to plot something: use class mglGraphZB or use class mglGraphPS (or mglGraphGL). Generally class mglGraphZB provide better quality of plot and require less memory but slower than mglGraphPS. It take place due to additional color/lighting interpolation and line/text smoothing in mglGraphZB. Also the speed of plot depend on the size of the picture and slightly depend on the size of data arrays (since it handle data rather quickly – it need few percent of drawing time).
    Note that in real situation some additional time may be required for data reading/creation or for saving picture to file. This time can be comparable or large then time for drawing picture itself.
  • I use VisualStudio, CBuilder or some other compiler. How can I link MathGL library?
    There are 2 ways. First is use the precompiled binary (*.dll). In this case you should make libraries for yours compiler from *.dll and *.def files. The corresponding command may look like lib.exe /def:libmgl.def. But such way provide you only pure C functions, not C++ classes. The matter is that there is no standard for C++ functions naming in object files. The standard was accepted only for C functions.
    The second way is to compile the library from sources. MathGL library have some external dependencies (PNG, GSL, JPEG, TIFF, FLTK, GLUT, HDF5), but most of them is optional. Some libraries can be found here. But also you may exclude from the project the corresponding files to disable usage of JPEG, TIFF, FLTK, GLUT, HDF5 libraries. Also you may define NO_GSL at compilation stage for disabling GSL support. At this some special functions in formulas, Fourier transform and nonlinear fitting will be disabled also.
    For excluding PNG support just comment the body of functions mgl_pnga_save(),mgl_png_save() in mgl_export.cpp. After it MathGL library will not depend on any external libraries. But in this case you should redirect the output to some window (as bitmap drawing from mglGraphZB|PS::GetBits() or mglGraphZB|PS::GetRGBA()) and save this bitmap to a file by yourself.

    Finally! Please do not ask me Windows-specific questions. I do not use Windows. I know nothing about Visual Basic, Visual C++, CBuiled or .NET. Please find the appropriate Usenet discussion group and ask your question there.

  • How many people write this library?
    The most of the library was written by one person. This is result of near a year of work (mostly in the evening and in holidays): half-year I spent for writing the kernel and half-year or year I spent for extending, improving and documentation writing. This process continues now :). The autoconf/automake script was written mostly by D.Kulagin, and export to IDTF was written mostly by M.Vidassov. Packages to particular platform (RPM or DEB) are prepared by other people (thanks to D. Kulagin, S. Plis, V. Lipatov and N. Troitsky).