I am generating a graph with gnuplot and then, I need to crop a part of it as a pdf or high-quality image to be used with LaTeX.

I have tried generating the graph as a pdf and then cropping it but it cannot be transformed with tools that would serve for other pdfs. I can open it with Evince but not with Okular or Pdf-Shuffler. I have also tried with Krop and Briss without sucess. Pdfcrop returns the following error:

!!! Error: Cannot find PDF header of 'my_graph.pdf'

I can take a screenshot of the pdf but I can cannot save it as a pdf and if saved as an image, the quality is not good enough.

I have found an old pdf-shuffler error that refers to pdfs that contain only an image. I wonder if my problem is related because the pdf includes only the graph. However, this problem has been solved and was only related to export, while I am unable to import.

I am using Ubuntu 17.10.

Is there any tool I can use to crop a gnuplot-generated graph to pdf (or high-quality image)?

How is this pdf file different from others of the same format?

  • You can crop the image directly inside a LaTeX \includegraphics environment, using the trim and clip parameters. See for example Crop an inserted image? – steeldriver Oct 11 at 12:34
up vote 0 down vote accepted

My file was not recognized by the cropping tools because I had not set up gnuplot properly.

As I had been working with eps before, I was using set terminal eps instead of set terminal pdf. After changing this, I can work normally with the pdf file.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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