Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to demonstrate LaTeX formula with Gnuplot?

Tags:

gnuplot

I have attempted to demonstrate a LaTeX formula with Gnuplot 5.0. But I found that some LaTeX commands are unavailable.

This is my Gnuplot Code:

set termoption enhanced

set title   "Title test^a \alpha $\alpha$" font "CMU-Serif, 18"
set xlabel  "Month"
set ylabel  "Precipitation (mm)"
set xrange  [0.5: 12.5]
set xtics   1,1,12
set key
set pointintervalbox 2

plot    "08_Data.dat"   using 1:2 with linespoints \
                        linecolor "#FF7800" linewidth 2 pointtype 7 pointsize 0.75 pointinterval -1 \
                        title "Beijing",\
        "08_Data.dat"   using 1:3 with linespoints \
                        linecolor "#00A0DC" linewidth 2 pointtype 7 pointsize 0.75 pointinterval -1 \
                        title "Shanghai",

set output
pause (-1)

As a result, the LaTeX command test^a works well but the LaTeX \alpha and $\alpha$ don't work:

enter image description here

This is the file: 08_Data.dat :

1       2.5     38.1
2       5.1     58.4
3       10.2    81.3    
4       25.4    101.6
5       27.9    114.3
6       71.1    152.4
7       175.3   129.5
8       182.9   132.1
9       48.3    154.9
10      17.8    61.0
11      5.1     50.8
12      2.5     35.6
like image 281
Luke Niu Avatar asked Nov 28 '25 02:11

Luke Niu


2 Answers

   set term tikz standalone size 7cm, 3cm fontscale 0.6
   set ylabel '{\LaTeX\ -- $ \gamma $}'
   set xlabel '{\LaTeX\ -- $ x $}'
   set output 'example.tex'
   plot [0:1] gamma(x) title '$ \gamma(x) $'
   unset output
   !pdflatex example

screenshot of pdf output

like image 78
Ethan Avatar answered Nov 29 '25 16:11

Ethan


Have you tried to directly type in the alpha character in the gnuplot code? I guess gnuplot understands UTF-8.

set title "test^a α α" font "CMU-Serif, 18"
plot x

Result:

enter image description here

like image 45
theozh Avatar answered Nov 29 '25 17:11

theozh