Sunday, August 28, 2011

How to use greek symbols in a Gnuplot graphic

This is the translation into English of a previous post in Spanish.

Using the Enhanced Postscript (EPS) terminal it's possible to add a lot of symbols to a Gnuplot graphic. The syntax is very similar to the Latex one.

There's a syntax guide which includes many examples.

To create the following graphic I used the EPS terminal to label the axes with greek letters:

This is my script:
set xrange [0:3]
set yrange [-2.5:4.5]
#Range and xtic interval
set xtics -3,0.5,10
#Range and ytic interval
set ytics -2.5,0.5,4.5

#Labels with greek letters
set xlabel "t/{/Symbol p}"
set ylabel "{/Symbol q}"

#Legend position
set key
set origin 0,0
#Ratio between heigth and width
set size ratio 0.5

#Color EPS terminal with Arial font is set as outoput terminal
set term post eps enhanced color "Arial" 11

#Graphic size
set size 1,1
#With Border
set border

#Output file
set output "theta.eps"

#Plot command
plot 'pos1.dat' using 1:2 title 'E=0.25' with lines, \
        'pos2.dat' using 1:2 title 'E=0.50' with lines, \
        'pos3.dat' using 1:2 title 'E=0.75' with lines, \
        'pos4.dat' using 1:2 title 'E=1.00' with lines, \
        'pos5.dat' using 1:2 title 'E=1.25' with lines

1 comment:

  1. Dear editor
    Hello I liked your explanation.
    I am trying to use your code, but for the first file it is plotted in lines but the 2nd and 3rd files are plotted in dashed lines, i have seen in your plot that your data has also dashed lines, even if i am indicating to use lines as in your code. Do you have any idea for plotting everything with continuous lines?
    Marco Polo