Workaround for matplotlib bug #3687

Closes #491
fix merge conflict when cherry-picking
test fix