Move matplotlib imports into functions