One βcleanβ way to install matplotlib is to go through pip:
sudo apt-get install python-pip sudo pip install matplotlib
It also ensures that you get the latest stable version and will be easier to maintain when the update is ported to pypi.
If the build process complains about missing header files, simply install the missing lib with:
sudo apt-get install libfreetype6-dev libpng-dev
Warning: it may take a long time to complete assembly, since one matplotlib dependency is numpy, which is quite a project in terms of c extension.
source share