Import matplotlib only when plotting