This is probably an issue with your PYTHONPATH environment variable, or a lack of one. Using apt-get, matplotlib will be installed into the /usr directory prefix. So you'll find the whole package installed somewhere like /usr/lib/python2.7/site-packages/matplotlib.
You can confirm this with a command like: dpkg -L python-matplotlib.
When you separately downloaded the matplotlib source, built and installed it yourself using the above commands, you will have installed it into the /usr/local prefix. This is good, as your system libraries (in /usr prefix) are managed by dpkg, and you don't want to overwrite or interfere with those files, for fear of breaking another, depending package or leaving stray, unmanaged files lying around.
Now, you're probably using the system-installed python. It comes pre-installed on (all?) Linux distros, so why wouldn't you? But this is installed in /usr. Python's default module search path is constructed from the prefix in which it is installed. So, your system python (configured with --prefix=/usr) will by default only search for modules installed in /usr/lib/python2.7, completely overlooking those modules you manually installed in /usr/local/lib/python2.7.
So, to work around this, here are some possible solutions:-
- (Don't do this!) Build and install matplotlib with - --prefix=/usr.
 
- Edit your - PYTHONPATHto include- /usr/local/lib/python2.7/site-packagesThis is a feasible solution when it's your own machine. You install packages there as root user, and edit- ~/.bashrcor- /etc/bash.bashrcto export the PYTHONPATH environment variable. It's a bit messy for a multi-user machine or server, as all these packages have to be upgraded manually by the root user, which might not always be convenient. Much better to leave it up to your system package manager.
 
- Install matplotlib 1.2 in to your user directory. You could later remove it when the repositories are updated to the version you require. 
`python setup.py install --user`
The latter method is my favourite method. I discovered it relatively recently, but it doesn't require editing any system or user-specific configuration files or environment variables, doesn't interfere with system packages, and doesn't need a sudo user to install.
This will install matplotlib into ~/.local/lib/python2.7 on Linux; into ~/Library/... on OS X and probably somewhere else on some other distros. Either way, this method is supported on all platforms and your user-specific modules will be loaded in preference to the system-wide ones.
Now go have fun with matplotlib. It's a great package!
P.S. Don't build packages as root user. I think it's bad practice to leave root owned files in user directories.
P.P.S. You can check where matplotlib (or any other python module) was loaded from within the Python interpreter. e.g.:-
>>> import matplotlib
>>> print matplotlib.__file__
/usr/lib/python2.7/site-packages/matplotlib/__init__.pyc