Formatting time series data for plotting