Converting data to plot relevant form