11.3 Multiple graphical output formats for the same plot

In most cases, you may want one image format for one plot, such as png or pdf. The image format is controlled by the chunk option dev (i.e., the graphical device to render the plots). This option can take a vector of device names, e.g.,

  1. ```{r, dev=c('png', 'pdf', 'svg', 'tiff')}
  2. plot(cars)
  3. ```

Only the first format is used in the output document, but the images corresponding to the rest of formats are also generated. This can be useful when you are required to submit figures of different formats additionally (e.g., you have shown a png figure in the report but the tiff format of the same figure is also required).

Note that by default, plot files are typically deleted after the output document is rendered. To preserve these files, please see Section 16.5.