Workaround for matplotlib bug #3687

Closes #491
Merge pull request #492 from ChrisBeaumont/491

Workaround matplotlib bug