allow selecting the backend by setting the environment variable MPL_BACKEND

This commit adds a new way of selecting the matplotlib backend. The `-d` flag can cause problems with scripts that use the command line arguments as parameters and don't ignore unknown ones. An environment variable `MPL_BACKEND` can be set by the user (or in the code) and is far less likely to cause problems than using the `-d` flag.
It looks like this line is superfluous, since you are catching KeyError.