I added a function to prepare the data for plotting with matplotlib