Separated truncate_data stuff in Plotting to seperate function
updated code snippets