![]() |
2014-06-09
, 07:24
|
Posts: 1,269 |
Thanked: 3,961 times |
Joined on May 2011
@ Brazil
|
#2
|
The Following User Says Thank You to rcolistete For This Useful Post: | ||
![]() |
2014-09-16
, 23:56
|
Posts: 1,269 |
Thanked: 3,961 times |
Joined on May 2011
@ Brazil
|
#3
|
![]() |
2014-09-22
, 21:52
|
Posts: 1,269 |
Thanked: 3,961 times |
Joined on May 2011
@ Brazil
|
#5
|
Thanks for that! I hope you'll port R to Sailfish too someday, can't wait to run/fiddle my scripts on the Jolla!
![]() |
2014-09-25
, 09:46
|
Posts: 752 |
Thanked: 2,808 times |
Joined on Jan 2011
@ Czech Republic
|
#7
|
I've tried to package R-base(-devel) .rpm package, but it seems to need Fortran compiler, which is not available on Mer/Sailfish.
Fortran is optional dependency for some packages (NumPy), and obligatory for others (SciPy, etc).
![]() |
2014-09-25
, 15:03
|
Posts: 1,269 |
Thanked: 3,961 times |
Joined on May 2011
@ Brazil
|
#8
|
![]() |
2014-10-19
, 23:27
|
Posts: 1,269 |
Thanked: 3,961 times |
Joined on May 2011
@ Brazil
|
#9
|
The Following User Says Thank You to rcolistete For This Useful Post: | ||
![]() |
2014-10-28
, 17:02
|
Posts: 1,269 |
Thanked: 3,961 times |
Joined on May 2011
@ Brazil
|
#10
|
The Following User Says Thank You to rcolistete For This Useful Post: | ||
MatPlotLib version history on Sailfish :
- v1.4.2 (26/10/2014) released for Sailfish (27/10/2014);
- v1.4.1 (18/10/2014) released for Sailfish (19/10/2014);
- v1.4.0 (26/08/2014) released for Sailfish (15/09/2014);
- v1.3.1 (10/10/2013) released for Sailfish (08/06/2014).
All releases above have Agg and WebAgg backends.
For MatPlotLib on MeeGo Harmattan, see the topic "MatPlotLib - 2D & 3D plots for MeeGo Harmattan".
Some graphics produced by using MatPlotLib 1.3.1 with NumPy 1.8.1 on a Nexus 4 running Sailfish. See more examples in post #2. 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.3 s).
$ python simple_plot.py
3D surface plot of a function of two variables (takes 5.0 s) :
$ python surface3d_demo.py
2D vector field plot (takes 2.4 s):
$ python convfield.py
Install Warehouse (OpenRepos.net client) for Sailfish OS, see the Jolla Tides guide with screenshots.
Then open Warehouse, search for "MatPlotLib", enable the repository, then install it.
MatPlotLib v1.4.2 for Sailfish OS depends on NumPy, python-pyparsing, python-pytz, python-dateutil, python-six and python-tornado, so they will be installed, everything taking approx. 45 MB of space after installation.
The default backend (where the figure is displayed) is Agg, a non interactive backend, so the plots are not shown in the screen and can only be saved to PNG, PDF, PS and SVG files (by using "savefig" command).
The WebAgg backend is also available, so the figures are displayed in a web browser with the URL http://127.0.0.1:8988/, it is interactive and suppport MatPlotLib animations. If you want to use the WebAgg backend by default, then in Terminal, type :
$ cd ~/.config
$ mkdir matplotlib
$ echo 'backend : WebAgg' > matplotlib/matplotlibrc
It is strongly suggested to also install IPython for Sailfish, so the interactive use of MatPlotLib/NumPy becomes a lot easier.
With IPython 2.3.0 for Sailfish there are 2 interfaces : IPython terminal and IPython Notebook.
As a simple example (just type the text after the "In [n]:" lines) in IPython terminal (open Terminal, type "cd" to go to "/home/nemo/" folder, then type "ipython") :
In [1]: from pylab import *
In [2]: x = randn(10000); hist(x, 100)
In [3]: savefig('histogram.png')
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 Sailfish smartphone can easily create PDF files of plots !
The same histogram above, but using "WebAgg" backend selected during the Python session :
In [1]: import matplotlib
In [2]: matplotlib.use('webagg')
In [3]: import matplotlib.pyplot as plt
In [4]: import numpy as np
In [5]: plt.hist(np.random.randn(10000),100)
In [6]: plt.show()
The backend cannot be changed after pylab or matplotlib.pyplot is loaded. One workaround is to use "matplotlib = reload(matplotlib)" before changing the backend.
To run IPython with PyLab (NumPy + MatPlotLib) in interactive mode in Terminal, there are many options, open the Terminal, then type :
- "ipython --matplotlib", then type "from pylab import *";
- "ipython", then type "%matplotlib", then "from pylab import *";
- "ipython --matplotlib", then type "import matplotlib.pyplot as plt", then "import numpy as np";
- "ipython", then type "%matplotlib", then "import matplotlib.pyplot as plt", then "import numpy as np";
- "ipython", then type "%pylab";
- "ipython -pylab" (deprecated form).
Time to load MatPlotLib 1.4.2 on Nexus 4 running Sailfish :
- 0.6s via "from matplotlib import *" ;
- 2.5s (with NumPy 1.9.0) via "import pylab" or "from pylab import *".
Compare with the Nokia N9 timings.
IPython Notebook also supports inline plots, just type "%pylab inline" (or "%matplotlib", then "import matplotlib.pyplot as plt", then "import numpy as np") inside the IPython Notebook session.
MatPlotLib documentation is online in the official MatPlotLib site, in PDF format (63MB and 2,600 pages), or help available in interactive mode by typing :
- "help(matplotlib)", after an "import matplotlib";
- "help(pylab)" or "help(pylab.matplotlib)", when using PyLab.
There is more than one hundred source code examples (.py Python files) in :
MatPlotLib gallery
MatPlotLib screenshots
MatPlotLib examples list
which can run on Sailfish.
For making plots with calculations using derivatives, integrals, etc, then SymPy is also available for Sailfish :
SymPy (Computer Algebra System) for Maemo 4 & 5 & MeeGo Harmattan & Sailfish.
By the way, be a Sailfish proud user : MatPlotLib 1.2.x/1.4.x is only available for Linux, Windows, Mac OS, iOS, MeeGo Harmattan and Sailfish.
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 ---
Sailfish : Sony Xperia X, Gemini, Jolla, Jolla C, Jolla Tablet, Nexus 4. Nokia N9, N900, N810.
Last edited by rcolistete; 2014-10-28 at 16:59. Reason: Updated to MatPlotLib 1.4.2