I currently have a reaction coordinate created with Gnuplot. I want the appearance of a. step function with the addition of dashed lines connecting each step. The x-coordinate is non-numerical. I am not sure the best way to describe this plot as I cant post a photo but if you search 'Free energy diagram' you will see what I mean. Thanks in advance to anyone who can help.
There is a total of 6 data points that need to be connected.
The data file has X coordinate (column 1): O_{2} , O@^*_{2}, OOH^* , O^* , OH^* , H_{2}O
and y-coordinate (Column 2): 0, -1, -2, -3, -4, -5
I will show how to draw each level with xerrorsteps style, and then draw a line connecting each level using "set arrow ...".
Data File "name":
O_{2} 0
O@^_{2} -1
OOH^ -2
O^* -3
OH^* -4
H_{2}O -5
Script:
#
# Load input data to datablock $ENERGY_LEVEL
#
set table $ENERGY_LEVEL
plot "data" using 0:(strcol(1)):2 with table
unset table
#
# Main routine
#
WIDTH = 0.7
DX = WIDTH/2.0
set border 3
set offset graph 0.1, graph 0.1, graph 0.2, graph 0.2
set xlabel "Reaction coordinate"
unset xtics
set ylabel "Free enegy level"
set ytics out nomirror
set errorbars 0
unset key
# Draw connected lines
LevelX(n) = real(word($ENERGY_LEVEL[n], 1))
LevelY(n) = real(word($ENERGY_LEVEL[n], 3))
do for [k=1:|$ENERGY_LEVEL|-1] {
set arrow nohead lc rgb 'black' lw 1 dt 3 \
from LevelX(k) + DX, LevelY(k) \
to LevelX(k+1) - DX, LevelY(k+1)
}
# Draw levels and labels
plot $ENERGY_LEVEL using 1:3:(DX) with xerrorbars ps 0 lc black lw 4, \
$ENERGY_LEVEL using 1:3:(strcol(2)) with labels offset 0,1
Description:
Since the given data format does not have a numerical value for the x-coordinate, an integer index is assigned to the first column when reading into the data block.