Generally I include images in my latex document by the command


However, after doing pdflatex the image quality is always very poor in the resulting pdf file. I think it is probably due to the scaling I do. I have also tried pdf, ps and eps images but they also suffer the same problems. I generally use gnuplot or matplotlib to generate the graphs.

What format should I store the images so that when I scale them to be put in the latex document, they maitain their quality? What are the macros that I should use? As of now I only use

  • 3
    Do you actually use the graphics package, or graphicx? You should be using the latter.
    – Jake
    Commented Jul 18, 2012 at 15:00
  • I just made a beamer presentation where I used the graphics package but yes in the past I have also used the graphicx package but without any change in quality
    – lovespeed
    Commented Jul 18, 2012 at 15:02
  • 3
    Use PDF (vector graphics) images when using pdflatex. Commented Jul 18, 2012 at 15:03
  • But it seems the plots generated by gnuplot as well as matplotlib in pdf are not very good in quality
    – lovespeed
    Commented Jul 18, 2012 at 15:04
  • 1
    @SthitadhiRoy Could you show in your question how you generate the pdf from gnuplot/matplotlib? Usually exporting to pdf should give you vector images, which means perfect quality at any zoom level.
    – matth
    Commented Jul 18, 2012 at 16:07

2 Answers 2


For diagrams you will get the best results when using vector graphics. Both gnuplot and matplotlib can export to vector graphics; file formats for vector graphics are e.g. eps or pdf or svg (there are many more).

As you are using pdfLaTeX, you should choose pdf as output format, because it will be easy to include in your document using the graphicx package and the \includegraphics{} command. To show you how to do it, I went to the matplotlib gallery and downloaded one of the many examples, saving it as myplot.pdf. The following code gives me absolutely satisfying quality.



Some text and \Blindtext .
  \caption{The figure caption should go below the figure.}
Some more text and \blindtext and a reference to figure~\ref{fig:myplot}.
Even more text and the end of the text.

PS: As discussed here, jpg is good for photos, png is good for e.g. screenshots.


The format of the graphic depends on the content. JPG is good for pictures, PNG was designed for content containing text.

For good print you will need a solution of at least 300 dpi.

Using a PDF as a container will not solve the problem of a poor graphic. So look at the format and the dots per inch of the image.

  • PDF as a container can contain pixel graphics or vector graphics. For graphs that you generate from own data, the best quality is achieved by using vector graphics. JPG and PNG are both pixel graphics, so you better don't use those for graphs and diagrams.
    – matth
    Commented Jul 18, 2012 at 16:01
  • 1
    PNG is certainly not designed for containing text. PNG is equivalent to JPG without lossy compression. PNG and JPG are only good for pictures (bitmap). PDF, SVG, EPS are good for graphics, illustrations, etc. (vector images)... and even for pictures. Commented Jul 18, 2012 at 16:24
  • 2
    @PolGab: PNG is by no means equivalent to JPG and one should choose between them wisely. For images of natural scenes JPG is a good choice if file-size is an issue. You will get compression artifacts but in natural images they are not too distracting. For images containing text, graphs or somthing similar, PNG is a good choice since it will not produce artifacts (well, it is always lossless) while JPG usually looks horrible or produces large files. Moreover, the techniques behind both formats are fundamentally different.
    – Dirk
    Commented Jul 18, 2012 at 19:37
  • @Dirk: PNG is better than JPG except in terms of file size. But vectorial formats like PDF, Postscript or SVG are infinitely better than PNG or JPG. Especially for everything that is text, graphs, illustrations build by software. Commented Jul 18, 2012 at 22:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .