Matplotlib backend kivy in Windows hands on
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.
Hi Andnovar
Thanks for these instructions. I understand that ‘python setup.py install’ installs a Python Package from source. Which package is being installed here?
David
Hello, the package installed is this one: http://kivy.org/downloads/1.9.0/Kivy-1.9.0-py2.7-win32-x86.exe. Then master https://github.com/kivy/kivy/archive/master.zip is renamed and replaced for the kivy-27 folder and reinstalled following the steps from the development kivy section. Similar with the other windows packages.
Thanks for answering my question.
I now have matplotlib successfully installed and I can run test_plt.py. Please could you provide an example that draws the plot on a widget (eg Boxlayout) specified by a .kv file? That would be closer to what I want to do.
Hi Andnovar
Please will you add some installation notes for Linux?
David
Hi David, for linux you can read the source code documentation (https://github.com/kivy-garden/garden.matplotlib/blob/master/backend_kivy.py), certainly I will move that to the readme of the garden package to make it more visible. If using linux after installing kivy and matplotlib you would need to install the garden as explained here: http://kivy.org/docs/api-kivy.garden.html .
garden install matplotlib
or
garden install –app matplotlib
should make it and you would be able to use the kivy.garden.matplotlib in your app. I will write a post about this from a fresh ubuntu installation later on.
Hi Andnovar
I’m really struggling to get this working on Fedora (it’s fine on Windows). I would be very grateful if you could provide some instructions for Linux please, even if it’s for Ubuntu.
Best regards
David
David I will write a post for linux np.
plz could you show as how to plot the function (sin) using garden.pyplot
Hi , this error appears to me. Any idea how to solve?
File “”, line 1163, in _load_backward_compatible
KeyError: ‘kivy.garden.matplotlib’
thanks
Hi, this error appears to me. Any idea how to solve?
File “”, line 2237, in _find_and_load
File “”, line 2226, in _find_and_load_unlocked
File “”, line 1191, in _load_unlocked
File “”, line 1163, in _load_backward_compatible
KeyError: ‘kivy.garden.matplotlib’
Thanks
I need to know more information. Are you running the examples that come with the package ? Which Kivy version are you using ?