Search code examples
rggplot2jpegdpi

How to export ggplot in R with 3543 pixels in JPEG format?


How to export ggplot with 3543 pixels (meaning: DPI resolution 1000 and 90 mm wide) in JPEG file?

I used this code but it does not function in my case:

jpeg(file="Traject_1.jpg", res=3543, width=9, pointsize=7, type="windows", antialias="cleartype")


Solution

  • You can use ggsave:

    ggsave("Traject_1.jpg", plot = yourplotname, device = "jpeg", width = 90, units = "mm", dpi = 1000)
    

    Documentation here.

    (NB: 1000 dpi is super high!)