1

I am trying to plot a function in gnuplot with epslatex terminal to be included in a Latex file:

reset
set terminal epslatex color
set xlabel '$x$'
set ylabel "$f(x)$" rotate by 90
set output 'out.tex'
plot x
set output

Then I use \input{out.tex} in the Latex file to include the plot in the resulting dvi file. Unfortunately,

  • there are no tick labels on either axis,
  • the y axis label is not rotated.

Interestingly, the tick labels are included in the generated out.tex file (e.g. \put(2410,484){\makebox(0,0){\strut{}$-5$}}%) but not displayed in the dvi file.

Also, the rotation for the y axis label is included in the out.tex file: \put(209,2761){\rotatebox{90}{\makebox(0,0){\strut{}$f(x)$}}}% but not rotated in the dvi file.

If I replace set terminal epslatex color with set terminal latex or even set terminal latex rotate then the tick labels appear but the y axis label is still not rotated.

It is also strange to me that if I compile the tex file with pdflatex (instead of latex) then the resulting pdf file only contains the tick mark labels and the axis labels (no frame, no axis, no ticks, no plot).

Can you please explain this behaviour?

1
  • It is normal for the dvi output to be missing some elements, they will be added later in the postscript format. Using latex example.tex, then dvips example.dvi, then ps2pdf example.ps results in the correct output for your code on my system, with the rotated f(x) label. I tried also with dvipdfm to convert the dvi directly to pdf but this didn't work properly, the labels were displayed but the location had shifted so it didn't align with the plot itself.
    – Marijn
    Sep 5, 2021 at 8:48

1 Answer 1

0

As @Marijn pointed out

It is normal for the dvi output to be missing some elements, they will be >added later in the postscript format. Using latex example.tex, then dvips >example.dvi, then ps2pdf example.ps results in the correct output with the rotated f(x) label.

On the other hand, the preamble was also not entirely appropriate. Changing \usepackage[dvips]{graphicx} to \usepackage[pdftex]{graphicx} or to \usepackage{graphicx} made the tex file work with pdflatex directly. For the correct operation, the texlive-font-utils package also needs to be installed (sudo apt-get install texlive-font-utils).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.