script to write plots