Application - MatPlotLib - 2D & 3D Plots for MeeGo Harmattan

Dec 13, 2011

MatPlotLib is a Python library for making 2D and 3D plots, usually using NumPy to calculate the data. See the MatPlotLib gallery to have an idea of which plots can be make using a Nokia N9/N950.

MatPlotLib 1.0.0 (30/07/2010) package is now released to MeeGo 1.2 Harmattan, with 3 installation files :
MatPlotLib-Doc (examples)
I am just the maintainer of MatPlotLib 1.0.0 for MeeGo 1.2 Harmattan and it is based on the Maemo 5 version of Simon Pickering.

Some graphics produced by using MatPlotLib on a Nokia N9. Download the .py (Python) script and using Terminal type in the the same directory the commands after the "$" :

2D plot of a function (sin) of one variable (takes 2.9 s).
$ python

3D surface plot of a function of two variables (takes 10.1 s) :
$ python

2D vector field plot (takes 2.8 s):
$ python

Installing MatPlotLib on MeeGo Harmattan :
Download to your Nokia N9/N950 the deb packages :
Open the Terminal, type :
$ devel-su
and the 'rootme' password, then type in the same directory where the above .deb was downloaded :
# cd ~user
# apt-get install python-central python-numpy
# apt-get install python-dateutil python-gobject python-cairo
# dpkg -i python-matplotlib-data_1.0.0-1_all.deb
# dpkg -i python-matplotlib_1.0.0-1_armel.deb
confirming the installation. The dependencies and packages above take almost 40 MB after install.
Then it is important to config the backend of MatPlotLib. Still as root :
# mkdir /usr/lib/python2.6/dist-packages/matplotlib/mpl-data
Then type "Ctrl+D" to go back to user. Then type :
$ cd ~
$ mkdir .matplotlib
$ echo 'datapath : /usr/share/matplotlib/mpl-data' > .matplotlib/matplotlibrc

Using MatPlotLib :
It is strongly suggested to also install IPython for MeeGo Harmattan, so the interactive use of MatPlotLib/NumPy becomes a lot easier.
Open the Terminal and type if IPython is installed :
$ ipython
or else :
$ python
As a simple example (just type the text after the "In [n]:" lines) :

In [1]: from pylab import *
In [2]: x = randn(10000)
In [3]: hist(x, 100)
In [4]: savefig('histogram.png')
The 1st line loads NumPy and MatPlotLib. The 2nd line calculates 10 thousand random numbers using NumPy. The 3rd line makes a histogram (but it doesn't show it). The last line saves the histogram to a PNG file 'histogram.png' in the current directory. To save a PDF figure, just type instead :
In [4]: savefig('histogram.pdf')
Yeah, your Nokia N9 can easily create PDF files of plots !

Limitations of MatPlotLib 1.0.0 on MeeGo Harmattan :
- there is not (yet ?) an interactive backend, so 'show()' does not work and should be replaced by "savefig('plotname.png')" (or any graphics format like png, pdf, ps, eps and svg).

So the more than one hundred source code examples (.py Python files) in :
MatPlotLib gallery
MatPlotLib screenshots
MatPlotLib examples list
can run on Nokia N9/N950 after replacing 'show()' by "savefig('plotname.png')" (for example).

For making plots with calculations using derivatives, integrals, etc, then SymPy is also available for MeeGo Harmattan :
SymPy (Computer Algebra System) for Maemo 4 & 5 & 6

By the way, be a N9/N950 proud user : MatPlotLib is only available for Linux, Windows, Mac OS, Maemo 5 and now MeeGo 1.2 Harmattan. Android and iOS, AFAIK, do not have MatPlotLib available.

Next steps for MatPlotLib on MeeGo Harmattan :
- show easy script examples (with documentation) to make the most useful plots (IN PROGRESS);
- release MatPlotLib packages in a public MeeGo Harmattan repository (App);
- try to release MatPlotLib 1.1.0 (06/10/2011), which includes animations, PySide compatibility (so, maybe, I say, maybe, interactive backend could run on Nokia N9/950);
- release softwares depending on MatPlotLib/Numpy with easy to use interface (in Qt Quick) to make from simple to complex plots of functions of 1 or 2 variables, of experimental data with error bars, eletrical vector field/potential, etc.



Source Maemo.Org

Leave a Reply

Your email address will not be published.


About us

IoT Gadgets is dedicated to bring you all the Internet of Things IoT news that pertains to gadgets. Simple. We love for you to join us on this journey.

Contact us: [email protected]


linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram