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

9. Python interface

MathGL provide the interface to a set of languages via SWIG library. Some of these languages support classes. The typical example is Python – which is denoted in the chapter title.

To use Python classes just execute ‘import mathgl’. The simplest example will be:

import mathgl
a=mathgl.mglGraph()
a.Box()
a.WritePNG('test.png')

Alternatively you can import all classes from mathgl module and easely access MathGL classes:

from mathgl import *
a=mglGraph()
a.Box()
a.WritePNG('test.png')

It become aloud if you will create many mglData object.

There are 2 classes in Python interface:

There is main difference from C++ classes – Python class mglGraph don't have variables (options). All corresponding features are moved to methods. The core of MathGL Python class is mglGraph class. It contains a lot of plotting functions for 1D, 2D and 3D plots. So most of sections is describe its methods. Its constructor have following arguments:

Constructor on mglGraph (Python): mglGraph (int kind=0, int width=600, int height=400)

Create the instance of class mglGraph with specified sizes width and height. Parameter type may have following values: ‘0’ – use mglGraphZB plotter (default), ‘1’ – use mglGraphPS plotter, ‘2’ – use mglGraphGL plotter, ‘3’ – use mglGraphIDTF plotter.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]
© manpagez.com 2000-2026
Individual documents may contain additional copyright information.