How do I add solid lines to the Free Energy Diagram plot and connect them?

Viewed 59

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

2 Answers

Thanks to @binzo's answer I guess it's clearer what it should be. Therefore, I remove my earlier attempts and place a different approach.

  • use the pseudocolumn 0 (which is the row number, zero-based) as x-coordinate, check help pseudocolumns).

  • (mis)use stats to get the data into strings which you can address by word() and index. Check help stats and help word.

  • you can also plot arrows with vectors (check help vectors)

Data: SO73734395.dat

(note, there was wrong formatting in the original question with O@^*_{2} and OOH^*)

O_{2}      0
O@^*_{2}  -1
OOH^*     -2
O^*       -3
OH^*      -4
H_{2}O    -5

Script:

### plot with errorbars, vectors and labelsh
reset session

FILE = "SO73734395.dat"

Labels = Levels = ''
stats FILE u (Labels=Labels." ".strcol(1),Levels=Levels." ".strcol(2)) nooutput
myLabel(i) = word(Labels,int(i+1))
myLevel(i) = real(word(Levels,int(i+1)))
N          = words(Labels)
dx         = 0.3

set offsets 0,0,0.5,0.5
set xlabel "Reaction coordinate"
set xrange[-0.5:N-0.5]
set ylabel "Free energy level"
set tics nomirror
set key noautotitle
set border 1+2
set errorbars 0

plot '+' u 0:(myLevel($0)):(dx) every ::::N-1 w xerr lc "black" ps 0 lw 2, \
      '' u ($0+dx):(myLevel($0)):(1-2*dx):(myLevel($0+1)-myLevel($0)) every ::::N-2 w vec lc "black" lw 1.5 dt 3 nohead, \
      '' u 0:(myLevel($0)):(myLabel($0)) every ::::N-1 w labels center offset 0,1
### end of script

Result:

enter image description here

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

enter image description here

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.

Related