data preparation and plotting