Home > Software design >  How can I edit this code to include a for-loop to make 30 output files as well as change the title f
How can I edit this code to include a for-loop to make 30 output files as well as change the title f

Time:10-01

I have to make 30 plots (30 output SVG files). Each plot requires one input file called 'step-x' where x = 1,2,3, ... 30. I was told to use a for-loop but am not sure how to. The code below is what I have so far.

Additionally I need to be able to change the title of the plot where it says set title "Associative Pathway (0,1)" and where it says title "{/:Bold 0.84 V}" for each individual plot.

Thanks in advance

#!/usr/local/Cellar/gnuplot/5.4.4/bin/gnuplot

set termoption font "Sans,22"
set border 15 front lt black linewidth 3.000 dashtype solid
set xrange [0:5.5]
set yrange[-5:0.1]
set title "Associative Pathway (0,1)"
set title  font "{/:Bold},23"
set xlabel "Reaction Coordinate"
set xlabel  font "{/:Bold,23}"
set ylabel "Free Energy (eV)"
set ylabel  font "{/:Bold,23}"
set xtic scale 0
set ytics out nomirror
set xtics nomirror
set xtics ("O_{2}" 0.3, "O@^*_{2}" 1.3, "OOH^*" 2.3  , "O^*" 3.3, "OH^*" 4.3 ,"H_{2}O" 5.3 ) font "{/:Bold},23"
set ytics font "{/:Bold},23"
## Last datafile plotted: "step-x"
p "step-1" u 7:8 w l dt 4 lc rgb 'blue' notitle, "step-1" u 2:3 w l lw 3 lc rgb 'blue' title "{/:Bold 0 V}"
rep "step-1" u 9:10 w l dt 4 lc rgb 'red' notitle, "step-1" u 4:5 w l lw 3 lc rgb 'red' title "{/:Bold 0.84 V}"
#    EOF

Below is the data file

    #X-title     #X-U(0)      #X-U(1.8) #y-title  #y-U(0)        #y-U(1.8)
#1           #2  #3       #4    #5    #6      #7  #8        #9    #10
O_{2}        0   0        0   -3.00  O_{2}    0.5  0         0.5 -3.00
O@^*_{2}     0.5 0        0.5 -3.00  O_{2}    1   -0.1       1  -3.04

O@^*_{2}     1   -0.1     1   -3.04  OOH^*    1.5 -0.1       1.5  -3.04
OOH^*        1.5 -0.1     1.5 -3.04  OOH^*    2   -1.00      2  -3.12

OOH^*        2   -1.00    2   -3.12  O^*      2.5 -1.0       2.5  -3.12
O^*          2.5 -1.00    2.5 -3.12  O^*      3   -2.00      3    -4.00

O^*          3    -2.00   3    -4.00 OH^*     3.5 -2.00      3.5  -4.00
OH^*         3.5  -2.00   3.5  -4.00 OH^*     4   -4.00      4   -4.50

OH^*         4   -4.00    4   -4.50  H_{2}O   4.5 -4.00      4.5 -4.50
H_{2}O       4.5 -4.00    4.5 -4.50  H_{2}O   5   -4.50      5   -4.50

H_{2}O       5   -4.50    5   -4.50
H_{2}O       5.5 -4.50    5.5 -4.50

CodePudding user response:

Glad that you added some data. This is essential for making reasonable suggestions. However, I wouldn't call your data above "simplified". You basically ignored the suggestions from the answers to enter image description here

  • Related