If it fails to install matplotlib on mac because the compiler cannot locate some freetype header files, and if you don’t have freetype, then first install it using brew for instance:
brew install freetype
Odds are the compiler still complains when you try the installation second time.
The reason is that many libraries are installed under /usr/X11 on mac, and they are not correctly located at compile time due to the non-canonical location. If you’re using pkg-config, an easy way to use them is to include the package database there in /usr/X11 when locating headers and libraries using pkg-config. Export the following variable before compiling matplotlib:
pip install matplotlib