upgraded plot.sh