Archive

Archive for September 1st, 2015

ggplot for python calling kivy matplotlib backend

September 1st, 2015 No comments

Based on the grammar of graphics, ggplot is a library for plotting graphs in R. By doing some readings seems like ggplot is a very good choice to produce multi-layered graphs. I found a package for python which provides a ggplot structure wrapped into matplotlib instructions. I gave it a try by installing it from source https://github.com/yhat/ggplot and then, since the library is heavily depending on matplotlib I changed the backend by default to use kivy by placing these two lines on top of each example tested:


import matplotlib
matplotlib.use('module://kivy.garden.matplotlib.backend_kivy')

The main advantage in my case is the minimum set of instructions required for creating plots. Some resources can be found here http://blog.yhathq.com/posts/ggplot-for-python.html. I have not fully tested it but I am giving it a try.

smooth.py ggplot

Matplotlib backend kivy in Windows hands on

September 1st, 2015 7 comments

The backend implementations for matplotlib in kivy work just with kivy versions greater or equal than 1.9.1. It is required to install kivy in development mode following these steps: http://kivy.org/docs/installation/installation-windows.html#use-development-kivy. After step 10 you can additionally run


python setup.py install

The script kivy.bat creates an environment in which some python tools are ready to use, for instance pip. The next step is to download numpy and matplotlib from this binaries repositories: http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy and http://www.lfd.uci.edu/~gohlke/pythonlibs/#matplotlib. Once downloaded install both using pip and then install kivy-garden and the matplotlib package for kivy.


pip install "numpy-1.10.0b1+mkl-cp27-none-win32.whl"
pip install "matplotlib-1.4.3-cp27-none-win32.whl"
pip install kivy-garden
garden install matplotlib

You can go now to the folder that by default garden packages are installed. In my case C:\Users\my_user\.kivy\garden\


cd garden.matplotlib/examples
python test_plt.py

And you should be able to see the matplotlib widget working on windows. Follow the steps from http://kivy.org/docs/installation/installation-windows.html#send-to-method to create a shortcut to execute your kivy apps.

Now you can go directly to the garden path using a file explorer, do right click on test_plt.py and send to kivy-2.7.bat which will start the application.

Categories: kivy, matplotlib Tags: , ,