Xmgrace landscape plots to landscape PDFs

This is a howto provided to me really kindly by my workmate Gisela. She wanted to transform an [[Encapsulated PostScript|EPS]] file obtained with [[Grace (plotting tool)|Xmgrace]] to PDF, but the landscape/portrait properties were messing around.

The setup is the following: we produce a landscape plot with Xmgrace, and save it as EPS. Then we want to convert it to PDF, but keeping its landscape nature. The problem is trickier that it sounds.

We need (all available at the repositories of most Linux distros):

  • Xmgrace
  • [[ImageMagick]]
  • ps2pdf

Steps to Sucess(tm), assuming an A4 paper size:

  1. In Xmgrace, go to Page setup, and choose A4
  2. Print the plot (whithin Xmgrace) to EPS format (fileL.eps)
  3. Rotate to portrait typing the following from a terminal:
    % convert fileL.eps -rotate "+90>" fileP.eps
    The greater than sign after the 90 meaning “rotate only if infile is landscape”.
  4. Convert to PDF:
    % ps2pdf -sPAPERSIZE=a4 fileP.eps
    (for Letter size, omit the “sPAPERSIZE” option)
  5. Rotate the PDF back to landscape:
    % convert fileP.pdf -rotate "-90<" fileL.pdf

That’s it.

Leave a Comment