I have some figures I'm making that consist of tens of thousands of points. The PDF version of one of these figures is 1.1 MB, while the PNG version is 1.3 MB (both figures generated with the matplotlib module of Python). I have dpi set to 400 for my PNG, overkill relative to the standard I know but I wanted to keep good resolution even if people zoom in on it.

Since the PDF version of the figure is slightly smaller, I figured that would be better to use as far as document load time is concerned. However, in my compiled document (compiled with pdflatex), the slightly larger PNG version of the figure appears virtually instantly, while it takes several seconds for the PDF version of the figure to load in the document.

Why is it that the smaller PDF figure takes so much longer to load?


This is not really a LaTeX question but simply the difference between vector graphics (pdf) and raster ones (png, jpg, etc.).

a raster graphics although it can be large is a simple object to display. It is only an X by Y image irrespective of what the image contains, and that it.

A vector graphic can be extremely complex, consisting of many object that the viewer needs to draw one at a time.

In your case, you have a vector graphic with 10,000s of objects which individually needs to be drawn. These objects can be dots, lines, curves, colour blocks, text which also include the font, etc... This will take a very long time. You might be able to make it faster by optimising the pdf but you will still have 10,000s of objects to draw.

  • 3
    Just as supplement: The pdf inclusion is faster because the engine only needs to copy the PDF stream into the final PDF. For PNG there needs to be a conversion. – TeXnician Jun 7 at 17:05
  • @KJO I referred to the compile time. That's why I called it a supplement. The viewer perspective is nicely covered by this answer. – TeXnician Jun 7 at 21:52

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.