There are several ways to go about installing matplotlib, some of which will depend on the system you are using. If you are lucky, you will be able to use a package manager to easily install the matplotlib module and its dependencies.
On Windows machines you can try to use the pip package manager to install matplotlib. See here for information on setting up pip in a Windows environment.
If you cannot use pip for whatever reason, then try to install from source.
Ideally, the system package manager or pip should be used to install matplotlib, either by installing the
python-matplotlib package or by running
pip install matplotlib.
If this is not possible (e.g. you do not have sudo privileges on the machine you are using), then you can install from source using the
python setup.py install --user. Typically, this will install matplotlib into
sudo apt-get install python-matplotlib
sudo yum install python-matplotlib
See the matplotlib website for advice on how to fix a broken matplotlib.