I want to load an image (PNG/JPEG) in RStudio and then display it. But when I run
plot(load.image("solidblack.png"), ann = FALSE, axes = FALSE, mar = c(0,0,0,0))
I get very substantial margins around my image, despite the mar
argument to plot
:
How can I fix this?
The image has class "cimg", and therefore plot
calls plot.cimg
, which ignores the "mar" argument
You could use display
, or set the mar
parameters before calling the plot:
library(imager)
x <- load.image("D:/solidblack.png")
display(x) # Shows in a new window
opar <- par(mar=c(0,0,0,0))
plot(x, axes=FALSE)
par(opar)