# NOT RUN {
# }
# NOT RUN {
# Note: if this is used inside a SpaDES module, do not define this
# function inside another function. Put it outside in a normal
# module script. It will cause a memory leak, otherwise.
if (!require("ggplot2")) stop("please install ggplot2")
fn <- function(d)
ggplot(d, aes(a)) +
geom_histogram()
sim <- simInit()
sim$something <- data.frame(a = sample(1:10, replace = TRUE))
Plots(data = sim$something, fn = fn,
types = c("png"),
path = file.path("figures"),
filename = tempfile(),
.plotInitialTime = 1
)
# plot to active device and to png
Plots(data = sim$something, fn = fn,
types = c("png", "screen"),
path = file.path("figures"),
filename = tempfile(),
.plotInitialTime = 1
)
# Can also be used like quickPlot::Plot, but with control over output type
r <- raster::raster(extent(0,10,0,10), vals = sample(1:3, size = 100, replace = TRUE))
Plots(r, types = c("screen", "png"), deviceArgs = list(width = 700, height = 500))
# }
# NOT RUN {
# end of dontrun
# }
Run the code above in your browser using DataLab