It doesn't work on Ubuntu 16.04, it seems that some libraries have been forgotten in the python installation package on this one. You should use package manager instead.
Uninstall matplotlib from pip then install it again with apt-get
python 2:
sudo pip uninstall matplotlib
sudo apt-get install python-matplotlib
python 3:
sudo pip3 uninstall matplotlib
sudo apt-get install python3-matplotlib