JPlotToPNG | R Documentation |
Writes the output of a plot to a PNG file. If you are using ggplot, try
either using JPlotToPNG(filename, print(<plotting code>))
or else
ggsave()
.
JPlotToPNG(
filename,
plotExpr,
width = 600,
height = NA,
aspectRatio = 3/2,
units = c("px", "mm", "cm", "in"),
tryToUseRagg = TRUE,
type = ifelse(capabilities()["cairo"], "cairo", NULL),
res = 72,
onlyIfDoesntExist = FALSE,
createDirectory = TRUE,
...
)
filename |
The name of the PNG to create or overwrite. If NULL, plot output goes to the current device. |
plotExpr |
A function or expression which will produce the plot to be written to the file. |
width |
The width of the output PNG file in |
height |
The height of the output PNG file in |
aspectRatio |
Aspect ratio ( |
units |
Units of |
tryToUseRagg |
If |
type |
Plotting device; passed directly to |
res |
The nominal resolution in ppi. The value is simply passed in to
|
onlyIfDoesntExist |
If TRUE and the output file already exists,
|
createDirectory |
If TRUE and |
... |
Any additional arguments are passed to either
|
The result of evaluating plotExpr
is returned invisibly (which
means it is not automatically printed).
agg_png
, png
## Not run:
JPlotToPNG("test.png", plot(rnorm(50), type = 'l', main = 'Wiggly line'))
# Plot to a PNG file with width 180 mm, height 120 mm
# (i.e. height / aspectRatio which defaults to (3 / 2)), resolution 300 ppi.
# This results in a PNG file with size 2125x1417 pixels
JPlotToPNG("test.png", plot(1:10 + rnorm(10), type = "o"), width = 180, units = "mm", res = 300)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.