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

1.6.2 Python interface

MathGL provides the interface to a set of languages via SWIG library. Some of these languages support classes. The typical example is Python – which is named in this chapter</samp>&rsquo;s title.

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

import mathgl
a=mathgl.mglGraph()
a.Box()
a.WritePNG(</samp>&rsquo;test.png</samp>&rsquo;)

Alternatively you can import all classes from mathgl module and easily access MathGL classes like this:

from mathgl import *
a=mglGraph()
a.Box()
a.WritePNG(</samp>&rsquo;test.png</samp>&rsquo;)

This becomes useful if you create many mglData objects, for example.

There are 2 classes in Python interface:

There is one difference from C++ classes – Python class mglGraph does not have variables (options). All the corresponding features are moved to methods. The core of MathGL Python class is the mglGraph class. It contains a lot of plotting functions for 1D, 2D and 3D plots. So most of the sections describe its methods. Its constructor has the 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-2025
Individual documents may contain additional copyright information.