[R] adding bmp/jpg/gif to an existing plot
baptiste auguie
baptiste.auguie at googlemail.com
Sat Dec 5 08:27:42 CET 2009
Hi,
If you can first convert the image to ppm format, the pixmap package
has an addlogo function that can do just what you want,
x <- read.pnm(system.file("pictures/logo.ppm", package="pixmap")[1])
plot(1:10,1:10)
addlogo(x, px=c(2, 4), py=c(6, 8), asp=1)
One could probably get inspiration from the addlogo code to make a
similar function for EBImage.
Alternatively, you could use Grid graphics as shown in this page,
http://wiki.r-project.org/rwiki/doku.php?id=tips:graphics-grid:displaybitmap
I wrote a similar function for EBImage that you can use to annotate
ggplot2 graphics.
HTH,
baptiste
2009/12/3 Cézar Freitas <cezarcamelo at gmail.com>:
> Hi, all.
> I searched a lot at mailing list, installed EBImage and gtk packages, but I
> couldn't make this simple work:
> How to add a image file (jpg or bmp ou gif) to an existing plot window (not
> plot over the image), like the code below (pseudo function add.image):
>
> plot(1:10,1:10,main="test")
> image = read.X("myimage.jpg")
>
> add.image(image, x.left=2, y.bottom=4, size="40%") #points the left-bottom
> corner and the reative size of image
>
> abline(x=3, col=2, lwd=2) #continues editing the plot window.
> text(2,3,labels="example of graphics and image")
>
> Is it possible?
>
> Thanks,
> Cezar Freitas
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
More information about the R-help
mailing list