extract data for plotting