implot | R Documentation |
This function lets you use an image as a canvas for base graphics, meaning you can use R functions like "text" and "points" to plot things on an image. The function takes as argument an image and an expression, executes the expression with the image as canvas, and outputs the result as an image (of the same size).
implot(im, expr, ...)
im |
an image (class cimg) |
expr |
an expression (graphics code to execute) |
... |
passed on to plot.cimg, to control the initial rendering of the image (for example the colorscale) |
an image
Simon Barthelme
plot, capture.plot
## Not run:
b.new <- implot(boats,text(150,50,"Boats!!!",cex=3))
plot(b.new)
#Draw a line on a white background
bg <- imfill(150,150,val=1)
implot(bg,lines(c(50,50),c(50,100),col="red",lwd=4))%>%plot
#You can change the rendering of the initial image
im <- grayscale(boats)
draw.fun <- function() text(150,50,"Boats!!!",cex=3)
out <- implot(im,draw.fun(),colorscale=function(v) rgb(0,v,v),rescale=FALSE)
plot(out)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.