'Save ggplot to stdout

Is it possible to save a ggplot figure to stdout, preferably with ggsave? How can I do this?

I am looking to do something like:

Rscript make_fig.R > my_fig.png


Solution 1:[1]

On Unix systems, it's posisble to use the device files:

ggsave(plot = p, filename = "/dev/stdout", device = "png")

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Jessica