Home » GNUPLOT Tricks

GNUPLOT Tricks

In this page I will discuss some GNUPLOT tricks and some examples based on our work in SAMPL5 challenge [LINK]. I think the example script files will be useful for people who are in simulation world and using GNUPLOT.
GNUPLOT Tricks
You can change the resolution of the output image using the size option:
set terminal png size <x,y>  
where x and y are the desired numbers of pixels along the horizontal and vertical axis, respectively. For example:
set terminal png size 1024,768
 
The every keyword allows a periodic sampling of a data set to be plotted.
Syntax:
     plot 'file' every {<point_incr>}
 Set font size
 set term png font "arial"

set term postscript eps font "Times-Roman,12"
How to set colorsequence?
 set colorsequence classic
Let’s do some application of GNUPLOT based on our datasets [Paper LINK]:
Here we plotted correlation between free energies derived from GAFF and OPLS force fields
set style line 7 lt 1 lc 7 lw 3 pt 5 ps 2

set style line 8 lt 1 lc 8 lw 3 pt 5 ps 2

set style line 9 lt 1 lc 9 lw 3 pt 5 ps 2

set style line 10 lt 1 lc 10 lw 3 pt 5 ps 2

set size square

set term postscript eps color 20

set output '../correlations_GAFF_OPLS_mmpbsa.eps'

set xrange [-20:-5]

set xlabel 'GAFF MM/PBSA (kcal/mol)'

set yrange [-20:-5]

set ylabel 'OPLS MM/PBSA (kcal/mol)'

p '../DAT_files/OAMe_gaff_opls_mmpbsa.dat' u 1:2 w p lt 1 pt 7 ps 2 lc rgb "blue" notitle,\

  '../DAT_files/Gu2_gaff_opls_mmpbsa.dat' u 1:2 w p lt 1 pt 5 ps 2 lc rgb "green" notitle,\

  '../DAT_files/OAH_gaff_opls_mmpbsa.dat' u 1:2 w p lt 1 pt 5 ps 2 lc rgb "red" notitle, x lt -1 notitle
 Result (image qualities are blurred because I am forced to convert the .eps file into .jpg file):

correlations_GAFF_OPLS_mmpbsa

We also plotted a free energy convergence plot of our simulations
set style line 1 lt 1 lc 1 lw 3 pt 5 ps 1.5

set style line 2 lt 1 lc 2 lw 3 pt 5 ps 1.5

set style line 3 lt 1 lc 3 lw 3 pt 5 ps 1.5

set style line 4 lt 1 lc 4 lw 3 pt 5 ps 1.5

set style line 5 lt 1 lc 5 lw 3 pt 5 ps 1.5

set style line 6 lt 1 lc 7 lw 3 pt 5 ps 1.5

set style line 7 lt 1 lc 8 lw 3 pt 5 ps 1.5

set style line 8 lt 1 lc 9 lw 3 pt 5 ps 1.5

set style line 9 lt 1 lc 10 lw 3 pt 5 ps 1.5

set style line 10 lt 1 lc 11 lw 3 pt 5 ps 1.5

set term postscript eps color 20

set output '../../convergence_OAMe_opls.eps'

set xrange [0:75]

set xlabel 'Time (ns)'

set yrange [-16:4]

set ylabel 'Free energy (kcal/mol)'

set key bottom right


p '../../OAMe/G1/OPLS/convonlyinner.dat' u 1:(($2+8.644283621+12.10000841)/4.1841) w l ls 1 title 'OAMe-G1',\

'../../OAMe/G2/OPLS/convonlyinner.dat' u 1:(($2+8.644283621+12.10000841)/4.1841) w l ls 2 title 'OAMe-G2',\

'../../OAMe/G3/OPLS/convonlyinner.dat' u 1:(($2+8.644283621+12.10000841)/4.1841) w l ls 3 title 'OAMe-G3',\

'../../OAMe/G4/OPLS/convonlyinner.dat' u 1:(($2+8.644283621+12.10000841)/4.1841) w l ls 4 title 'OAMe-G4',\

'../../OAMe/G5/OPLS/convonlyinner.dat' u 1:(($2+8.644283621+12.10000841)/4.1841) w l ls 5 title 'OAMe-G5',\

'../../OAMe/G6/OPLS/convonlyinner.dat' u 1:(($2+8.644283621+12.10000841)/4.1841) w l ls 7 title 'OAMe-G6',\
 Result:

convergence_OAH_opls

Let’s do some more fancy stuff:
Look here, we plotted a 1D free energy surface (with std. deviation)
set style line 1 lt 1 lc 1 lw 3 pt 5 ps 1.5

set style line 2 lt 1 lc 2 lw 3 pt 5 ps 1.5

set style line 3 lt 1 lc 3 lw 3 pt 5 ps 1.5

set style line 4 lt 1 lc 4 lw 3 pt 5 ps 1.5

set style line 5 lt 1 lc 5 lw 3 pt 5 ps 1.5

set style line 6 lt 1 lc 7 lw 3 pt 5 ps 1.5

set style line 7 lt 1 lc 8 lw 3 pt 5 ps 1.5

set style line 8 lt 1 lc 9 lw 3 pt 5 ps 1.5

set style line 9 lt 1 lc 10 lw 3 pt 5 ps 1.5

set style line 10 lt 1 lc 11 lw 3 pt 5 ps 1.5

set term postscript eps color 20

set output '../../plotconv_free_OAMe_stdev.eps'

set xrange [0.2:2]

set xlabel 'z (nm)'

set yrange [-20:3]

set ylabel 'PMF (kcal/mol)'

set key bottom right

set title 'GAFF'

p '../../OAMe/G2/GAFF/fes1d_tavg' u 1:(($2+73.3568)/4.1841)  w l ls 2 lc 2 lw 2 title 'OAMe-G2', '../../OAMe/G2/GAFF/fes_stdev' every 5 u 1:(($2+73.3568)/4.1841):($3/4.1841) w errorbars ps 0 lw 2 lt 1 lc 2 notitle ,\

'../../OAMe/G4/GAFF/fes1d_tavg' u 1:(($2+77.7595)/4.1841)  w l ls 4 lc 4 lw 2 title 'OAMe-G4', '../../OAMe/G4/GAFF/fes_stdev' every 5 u 1:(($2+77.7595)/4.1841):($3/4.1841) w errorbars ps 0 lw 2 lt 1 lc 4 notitle


set output '../../plotconv_free_OAH_stdev.eps'

set xrange [0.2:2.0]

set yrange [-20:3]
 

p '../../OAH/G2/GAFF/fes1d_tavg' u 1:(($2+66.989)/4.1841)  w l ls 2 lc 2 lw 2 title 'OAH-G2', '../../OAH/G2/GAFF/fes_stdev' every 5 u 1:(($2+66.989)/4.1841):($3/4.1841) w errorbars ps 0 lw 2 lt 1 lc 2 notitle ,\

'../../OAH/G4/GAFF/fes1d_tavg' u 1:(($2+54.5362)/4.1841)  w l ls 4 lc 4 lw 2 title 'OAH-G4', '../../OAH/G4/GAFF/fes_stdev' every 5 u 1:(($2+54.5362)/4.1841):($3/4.1841) w errorbars ps 0 lw 2 lt 1 lc 4 notitle
 Result:

plotconv_free_OAH_stdev

here is a fancy 2D free energy surface
set encoding iso_8859_1

set output '../../plot2d_g2.eps'

set xrange [0.2:2.0]

set xlabel 'z (nm)'

set yrange [-1.2:1.14]

set ylabel 'Orientation (cos {/Symbol q})'

#set cblabel 'PMF (kcal/mol)'

set cbrange [-17:5]

set pm3d map

splot '../../OAMe/G2/GAFF/fes2d' using 1:2:(($3+54.2104)/4.1841) notitle

set output '../../plot2d_g4.eps'

splot '../../OAMe/G4/GAFF/fes2d' using 1:2:(($3+56.6541)/4.1841) notitle
 Result:

plot2d_g4

%d bloggers like this: