I have the following script in gnuplot which works fine except for some font issues.
#!/usr/bin/env gnuplot
# setup
set terminal pngcairo enhanced color notransparent background rgb "white"
set output "temp.png"
lm="Latin Modern Math"
# range
set xrange [-3*pi/2:3*pi/2]
set yrange [-1.5:1.5]
# labels
set xlabel "{/Symbol q} (radian)" font lm
set ylabel "sin({/Symbol q}), cos({/Symbol q})" font lm
set title "Simple Sinusoid" font lm
# plot
plot sin(x) with lines linecolor rgb "red" title "sine", 0 title ''
set output
As you can see:
font
command after the title
but it did not workAny ideas? Thanks!
Edit The reason I want to use "Latin Modern" is because of consistency with the rest of the document (into which this will be included) which uses the same font.
You are probably looking for set key font lm
. Furthermore, gnuplot should be able to understand utf-8, so you can directly place θ in your labels. Since I don't have 'Latin Modern Math', I used "Lucida Graphic Italic" and "Courier New" for illustration. Another option would be to specify font in the terminal, e.g. set terminal pngcairo font "<whatever>"
. Check help pngcairo
.
Code:
### set fonts
reset session
set terminal pngcairo enhanced color notransparent background rgb "white"
set output "temp.png"
myFont = "Lucida Graphic Italic"
myFont2 = "Courier New"
# range
set xrange [-3*pi/2:3*pi/2]
set yrange [-1.5:1.5]
# labels
set title "Simple Sinusoid" font myFont
set xlabel "θ (radian)" font myFont
set xtics font myFont2
set ylabel "sin(θ), cos(θ)" font myFont
set ytics font myFont2
set key font myFont
# plot
plot sin(x) with lines linecolor rgb "red" title "sine", 0 title ''
set output
### end of code
Result: