switch backend only if necessary

This suppresses warnings on older matplotlib version, when the
backend is switched to on already active version.