Move matplotlib imports inside methods