Using matplotlib
improving code