Reply
Thread Tools
Posts: 928 | Thanked: 2,180 times | Joined on May 2011 @ Brazil
#1
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.

There are 2 versions to choose to install on MeeGo Harmattan :
- new MatPlotLib 1.2.1 (26/03/2013), released for MeeGo Harmattan in 05/06/2013, available in my Harmattan repository;
- MatPlotLib 1.0.0 (06/07/2010), released on MeeGo Harmattan in 24/11/2011, available in my Harmattan repository for manual download.

MatPlotLib 1.2.1 x 1.0.0 packages on MeeGo Harmattan:
- v1.2.1 is newer (26/03/2013) than v1.0.0 (06/07/2010);
- v1.2.x has a graphical backend (Qt4App/PySide) to interactively show plots;
- automatic configuration in v1.2.x, so no need to create directories and matplotlibrc file like in v1.0.0;
- v1.2.x is based on upstream and Ubuntu 13.04 versions, while v1.0.0 is based on the Maemo 5 version of Simon Pickering;
- many new features, see the "MatPlotLib What's New" : animation, new types of plots, many improvements in 3D plots, etc.

Version history :
- MatPlotLib 1.2.1-2 Harmattan release (15/06/2013);
- MatPlotLib 1.2.1-1 (26/03/2013) released for MeeGo Harmattan (06/06/2013);
- MatPlotLib 1.2.0-2 Harmattan release (12/02/2013);
- MatPlotLib 1.2.0-1 (08/01/2013) released for MeeGo Harmattan (09/02/2013).

For MatPlotLib on Sailfish/Mer, see the topic "MatPlotLib - 2D & 3D plots for Sailfish".

Examples and screenshots of MatPlotLib on MeeGo Harmattan

Some graphics produced by using MatPlotLib 1.2 with NumPy 1.4.1 on a Nokia N9. See more examples in post #4. 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 4.4 s).
$ python simple_plot.py


Qt4/PySide backend showing a plot of one variable, f=f(x), of a damped harmonic oscillator, see plotfx.py script in post #4, where the "savefig" command was commented and "show()" was uncommented :


3D surface plot of a function of two variables (takes 9.7 s) :
$ python surface3d_demo.py


The same above, shown by the Qt4/PySide backend using "plt.show()" instead of "plt.savefig" in the script, allows to touch to rotate the 3D plot :


2D vector field plot (takes 4.6 s):
$ python convfield.py


Installing MatPlotLib on MeeGo Harmattan

See post #33 if you want to install MatPlotLib 1.0.0. The instructions below are for MatPlotLib 1.2.1.

After configuring my Harmattan repository, open the Terminal, type :
$ devel-su
and the 'rootme' password, then
# apt-get update
# apt-get install python-matplotlib
confirming the installation. The MatPlotLib packages and dependencies (1.7.x) take almost 50 MB after install.

To remove any conflicting configuration of MatPlotLib 1.0.0 (previous versions), type in Terminal as user :
$ cd ~
$ rm -rf .matplotlib

The Qt4/PySide graphical backend assumes PySide is installed (which is used by many MeeGo Harmattan softwares). If you want Qt4/PySide backend and PySide is not installed, it is simple to install it, just type in Terminal as root :
# apt-get install python-pyside
If you don't want to use an interactive graphical backend (i.e., Qt4/PySide) by default, then as user in Terminal, type :
$ cd ~
$ mkdir .matplotlib
$ echo 'backend : Agg' > .matplotlib/matplotlibrc
so the Agg backend becomes the default one. With non interactive backend, the plots are not shown in the screen and can only be saved to files (by using "savefig" command).

Using MatPlotLib on MeeGo Harmattan

It is strongly suggested to also install IPython for MeeGo Harmattan, so the interactive use of MatPlotLib/NumPy becomes a lot easier
With the new IPython 0.13.1-2 Harmattan, there are 3 interfaces : IPython terminal, IPython Notebook and IPython Qt console.


As a simple example (just type the text after the "In [n]:" lines) in IPython terminal :

In [1]: from pylab import *
In [2]: x = randn(10000); hist(x, 100)
In [3]: savefig('histogram.png')
In [4]: show()
The 1st line loads NumPy and MatPlotLib by using PyLab. The 2nd line calculates 10 thousand random numbers using NumPy, and makes a histogram (not shown in the screen). The 3rd line saves the histogram to a PNG file 'histogram.png' in the current directory (it could be a PDF figure, just use '.pdf' extension). Yeah, your Nokia N9 can easily create PDF files of plots ! The 4th line shows the plot in the interactive Qt4/PySide default backend of MatPlotLib 1.2, see below :

The interactive Qt4/PySide default backend is not touch friendly (as there is no mouse and the N9/N950 screen is small compared to a desktop PC), so only some features are practical to use. But it shows the plot in full screen since MatPlotLib 1.2 Harmattan (12/02/20130 allows to rotate 3D plots, etc.

To run IPython with PyLab (NumPy + MatPlotLib) in interactive mode in Terminal, there are many options :
- tap the IPython icon (v0.13.1), then type "%pylab";
- open the Terminal, type "ipython", then type "%pylab";
- open the Terminal, type "ipython --pylab".

See post #32 for time measurements of MatPlotLib 1.2.0 x 1.0.0 with NumPy 1.4.1 and 1.7.0.

IPython Notebook and IPython Qt console also support inline plots, just type "%pylab inline" inside the IPython Notebook session :


Or IPython Qt console session :


Documentation and Examples for MatPlotLib

MatPlotLib documentation is online in the official MatPlotLib site, in PDF format (16MB and more than 1,2 thousand pages), or help available in interactive mode by typing :
- "help(matplotlib)", after an "import matplotlib";
- "help(pylab)" or "help(pylab.matplotlib)", when using PyLab.

The package "python-matplotlib-doc_*.deb" only contains examples, but anyway it is purged as everything is in "/usr/share/doc/".

There is more than one hundred source code examples (.py Python files) in :
MatPlotLib gallery
MatPlotLib screenshots
MatPlotLib examples list
which can run on Nokia N9/N950.

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 1.2 is only available for Linux, Windows, Mac OS and now MeeGo 1.2 Harmattan.

Next steps for MatPlotLib on MeeGo Harmattan :
- (DONE, see this post and post #4) show easy script examples (with documentation) to make the most useful plots;
- (DONE, see my Harmattan repository) release MatPlotLib packages in a public MeeGo Harmattan repository (App);
- (DONE, now with MatPlotLib 1.2.0 there is a interactive backend on Nokia N9/N950) try to release MatPlotLib 1.1 or 1.2, which includes animations, PySide compatibility (so, maybe, I say, maybe, interactive backend could run on Nokia N9/950);
- (DONE, see MatPlotLib 1.2.0 Harmattan2) try to show Qt4/PySide backend in full screen;
- 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.
__________________
Python, C/C++, Qt and CAS developer. For Maemo/MeeGo/Sailfish :
Integral, Derivative, Limit - calculating mathematical integrals, derivatives and limits. SymPy - Computer Algebra System.
MatPlotLib - 2D & 3D plots in Python. IPython - Python interactive shell.
-- My blog about mobile & scientific computing ---
2 Nokia N9 16GB Black @ 1.35 GHz, 1 with Sailfish, Stowaway foldable BT keyboard.
Nexus 4 with Sailfish. Nokia N900 @ 1.1 GHz. N810. Nokia 9500. Psion Revo+.

Last edited by rcolistete; 2014-06-17 at 18:00. Reason: Cited MatPlotLib 1.3.1 for Sailfish
 

The Following 16 Users Say Thank You to rcolistete For This Useful Post:
Posts: 26 | Thanked: 202 times | Joined on Oct 2009 @ Munich, Germany
#2
from pylab import *
does not work for me after your described procedure:
No module named pylab
 

The Following 2 Users Say Thank You to vielfrass For This Useful Post:
Posts: 928 | Thanked: 2,180 times | Joined on May 2011 @ Brazil
#3
Originally Posted by vielfrass View Post
from pylab import *
does not work for me after your described procedure:
No module named pylab
Please, give me the full error message.

Also check if, using Terminal :
$ apt-cache show python-matplotlib
shows a lot of information about the package (to confirm if it is installed).
__________________
Python, C/C++, Qt and CAS developer. For Maemo/MeeGo/Sailfish :
Integral, Derivative, Limit - calculating mathematical integrals, derivatives and limits. SymPy - Computer Algebra System.
MatPlotLib - 2D & 3D plots in Python. IPython - Python interactive shell.
-- My blog about mobile & scientific computing ---
2 Nokia N9 16GB Black @ 1.35 GHz, 1 with Sailfish, Stowaway foldable BT keyboard.
Nexus 4 with Sailfish. Nokia N900 @ 1.1 GHz. N810. Nokia 9500. Psion Revo+.

Last edited by rcolistete; 2011-11-25 at 07:48.
 

The Following 2 Users Say Thank You to rcolistete For This Useful Post:
Posts: 928 | Thanked: 2,180 times | Joined on May 2011 @ Brazil
#4
Here are some useful examples/templates scripts for ploting with MatPlotLib/NumPy. They have many options to change : domain, function, labels, title, etc. To adapt them to your use, just open the .py file with a text editor (for example Nano for Nokia N9 in Nokia Store), change the definitions in the section "# Personalize your plot parameters here", save and run (using Terminal) :
$ python <scriptname>.py
Timings for MatPlotLib 1.2.0 and NumPy 1.4.1 on Nokia N9.

plotfx.py : Plot of one variable, f=f(x), saving to a (PNG) file. Takes 8.4 s on Nokia N9.


contourfxy.py : contour plot of two variables, f=f(x,y), saving to a (PNG) file. Takes 10.2 s on Nokia N9.


densityfxy.py : density shaded relief plot of two variables, f=f(x,y), saving to a (PNG) file. Takes 10.3 s on Nokia N9.


vectorfieldFxy.py : vector field plot in 2D, F=F(x,y), saving to a (PNG) file. Takes 8.2 s on Nokia N9.


surfacefxy.py : surface plot of two variables, f=f(x,y), saving to a (PNG) file. Takes 16.6 s on Nokia N9.
__________________
Python, C/C++, Qt and CAS developer. For Maemo/MeeGo/Sailfish :
Integral, Derivative, Limit - calculating mathematical integrals, derivatives and limits. SymPy - Computer Algebra System.
MatPlotLib - 2D & 3D plots in Python. IPython - Python interactive shell.
-- My blog about mobile & scientific computing ---
2 Nokia N9 16GB Black @ 1.35 GHz, 1 with Sailfish, Stowaway foldable BT keyboard.
Nexus 4 with Sailfish. Nokia N900 @ 1.1 GHz. N810. Nokia 9500. Psion Revo+.

Last edited by rcolistete; 2013-02-11 at 16:42. Reason: Timings for MatPlotLib 1.2.0.
 

The Following 6 Users Say Thank You to rcolistete For This Useful Post:
Posts: 26 | Thanked: 202 times | Joined on Oct 2009 @ Munich, Germany
#5
Originally Posted by rcolistete View Post
$ apt-cache show python-matplotlib
shows a lot of information about the package (to confirm if it is installed).
Thanks for the hint. I'm a Python newbie. Seems to installed uncomplete. I'm doing the procedure again.
 

The Following 2 Users Say Thank You to vielfrass For This Useful Post:
Posts: 26 | Thanked: 202 times | Joined on Oct 2009 @ Munich, Germany
#6
Originally Posted by rcolistete View Post
Please, give me the full error message.
$ apt-cache show python-matplotlib
shows a lot of information about the package (to confirm if it is installed).
Actually reading the error message helps, some times...

This fixed it:
Code:
apt-get install python-central
Thanks a lot. This will help me learning Python and becoming more independent from MatLab.
 

The Following 2 Users Say Thank You to vielfrass For This Useful Post:
Posts: 26 | Thanked: 202 times | Joined on Oct 2009 @ Munich, Germany
#7
Will it be possible to have the QT iPython console on the N9 some day?
http://ipython.org/ipython-doc/dev/i...qtconsole.html
 

The Following User Says Thank You to vielfrass For This Useful Post:
Posts: 928 | Thanked: 2,180 times | Joined on May 2011 @ Brazil
#8
Originally Posted by vielfrass View Post
Actually reading the error message helps, some times...

This fixed it:
Code:
apt-get install python-central
Thanks a lot. This will help me learning Python and becoming more independent from MatLab.
It was my fault, 'python-central' was missing in the installation instructions above. It was already installed in my Nokia N9 (due to 'python-imaging') and I missed this detail...

The installation instructions are now fixed and complete.

Thank you very much.
__________________
Python, C/C++, Qt and CAS developer. For Maemo/MeeGo/Sailfish :
Integral, Derivative, Limit - calculating mathematical integrals, derivatives and limits. SymPy - Computer Algebra System.
MatPlotLib - 2D & 3D plots in Python. IPython - Python interactive shell.
-- My blog about mobile & scientific computing ---
2 Nokia N9 16GB Black @ 1.35 GHz, 1 with Sailfish, Stowaway foldable BT keyboard.
Nexus 4 with Sailfish. Nokia N900 @ 1.1 GHz. N810. Nokia 9500. Psion Revo+.

Last edited by rcolistete; 2011-11-26 at 22:05.
 

The Following User Says Thank You to rcolistete For This Useful Post:
Posts: 928 | Thanked: 2,180 times | Joined on May 2011 @ Brazil
#9
Originally Posted by vielfrass View Post
Will it be possible to have the QT iPython console on the N9 some day?
http://ipython.org/ipython-doc/dev/i...qtconsole.html
I have answered your question in iPython for MeeGo Harmattan topic.

But my priority is to (try to) release MatPlotLib 1.1 with a possible Qt backend running on Nokia N9/N950.
__________________
Python, C/C++, Qt and CAS developer. For Maemo/MeeGo/Sailfish :
Integral, Derivative, Limit - calculating mathematical integrals, derivatives and limits. SymPy - Computer Algebra System.
MatPlotLib - 2D & 3D plots in Python. IPython - Python interactive shell.
-- My blog about mobile & scientific computing ---
2 Nokia N9 16GB Black @ 1.35 GHz, 1 with Sailfish, Stowaway foldable BT keyboard.
Nexus 4 with Sailfish. Nokia N900 @ 1.1 GHz. N810. Nokia 9500. Psion Revo+.

Last edited by rcolistete; 2011-11-27 at 00:32.
 

The Following User Says Thank You to rcolistete For This Useful Post:
Posts: 9 | Thanked: 1 time | Joined on Feb 2012
#10
Hello !

I had just a little problem when i try to install the Library...

When i enter this command : " # dpkg -i python-matplotlib-data_1.0.0-1_all.deb "

My N9 returning this error : "Aegis rejecting python-matplotlib-data_1.0.0-1_all.deb : Could not open debian archive
Aegis aborting dpkg -- all listed package files rejected


Sorry for my approxymatly english .. i'm french ^^
 

The Following User Says Thank You to blinkman04 For This Useful Post:
Reply

Thread Tools

 
Forum Jump


All times are GMT. The time now is 07:39.