The hardware and bandwidth for this mirror is donated by METANET, the Webhosting and Full Service-Cloud Provider.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]metanet.ch.
Save a ggplot2 plot using + instead of breaking out of
the pipe for a separate ggsave() call.
library(ggplot2)
library(ggsnap)
mtcars |>
ggplot(aes(mpg, wt)) +
geom_point() +
labs(title = "Cars") +
ggsnap("cars.png", width = 6, height = 4)No more splitting a plot-building chain into an assignment plus a
separate ggsave() call:
# Without ggsnap
p <- mtcars |>
ggplot(aes(mpg, wt)) +
geom_point() +
labs(title = "Cars")
ggsave("cars.png", p, width = 6, height = 4)
# With ggsnap
mtcars |>
ggplot(aes(mpg, wt)) +
geom_point() +
labs(title = "Cars") +
ggsnap("cars.png", width = 6, height = 4)ggsnap() accepts the same arguments as ggplot2::ggsave(),
and ggsave_snap() is provided as an alias for
discoverability.
# Install from CRAN
install.packages("ggsnap")
# Install latest development version
remotes::install_github("orgadish/ggsnap")Since the plot is returned invisibly, ggsnap() can also
be called more than once in a chain, to save intermediate states:
mtcars |>
ggplot(aes(mpg, wt)) +
geom_point() +
ggsnap("base.png") +
theme_minimal() +
ggsnap("minimal.png")These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.