Optimized the data reading and plotting.