code for extracting data and plotting histogram