Save the graphics as PostScript and use ImageMagick convert to convert to JPEG with the desired density, for example:
ggsave(my_plot, file="foo.ps")
Then, to make a 300 dpi version of JPEG:
$ convert foo.ps -density 300 foo.jpeg
You will have a smaller file that you can display at any resolution and any bitmap format supported by ImageMagick.
If this is for the web, consider converting to SVG or PDF:
$ convert foo.ps foo.svg
You can easily embed SVG in an iframe , and this makes it easy to smoothly scale with small file sizes compared to high-resolution bitmaps.
source share