[R] import a bitmap image and add it to graphics display
Roger Bivand
Roger.Bivand at nhh.no
Fri Aug 6 17:54:53 CEST 2004
On Thu, 5 Aug 2004, Wolfram Fischer wrote:
> > Hello
> >
> > Is there a possibility to import and add a bitmap image (png or
> > similar) to a R graphics display. It would be helpful e.g. to
> > locate positions of points of a scanned map or to add a background
> > to a R graphic.
> >
> > Wolfram
>
> I found the package pixmap with the functions
> x <- read.pnm( file )
> and
> plot(x)
> This plots pnm pictures as R graphics.
> (Other picture formats can be converted to pnm pictures
> by several pnm commands on Linux or by using gimp.)
>
> Overlaying such a picture with a graph could be done as follows:
> library(pixmap)
> example(pixmap)
> plot(x)
> m <- 20 ; points( x=m*c(0,1,2), y=m*c(0,2,1), col='red', type='b', lwd=5 )
>
> There rests a problem with the scale:
> Question: How can I scale a pixmap object?
>
This is covered in the code for the addlogo function in the pixmap
package:
> help("addlogo-methods")
> getMethod("addlogo", "pixmap")
which uses the pixmap bounding box and user-supplied coordinates and an
aspect argument to scale a pixmap object. If the function itself doesn't
do what you need, it does show the slots you could use directly.
Roger
> Wolfram
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>
--
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Breiviksveien 40, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 93 93
e-mail: Roger.Bivand at nhh.no
More information about the R-help
mailing list