moved matplotlib import to improve performance