Preprocessing and plotting