Chapter 27. Understanding the Most Commonly Used Image File Formats

Anybody who is making figures for data visualization will eventually have to know a few things about how figures are stored on the computer. There are many different image file formats, and each has its own set of benefits and disadvantages. Choosing the right file format and the right workflow can alleviate many figure preparation headaches.

My own preference is to use PDF for high-quality publication-ready files and generally whenever possible, PNG for online documents and other scenarios where bitmap graphics are required, and JPEG as the final resort if the PNG files are too large. In the following sections, I explain the key differences between these file formats and their respective benefits and drawbacks.

Bitmap and Vector Graphics

The most important difference between the various graphics formats is whether they are bitmap or vector (Table 27-1). Bitmaps or raster graphics store the image as a grid of individual points (called pixels), each with a specified color. By contrast, vector graphics store the geometric arrangement of individual graphical elements in the image. Thus, a vector image contains information such as “there’s a black line from the top-left corner to the bottom-right corner, and a red line from the bottom-left corner to the top-right corner,” and the actual image is recreated on the fly as it is displayed on screen or printed.

Table 27-1. Commonly used image file formats
Acronym

Get Fundamentals of Data Visualization now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.