Using Roger's rather useful addlogo() function (still included below), I am unable to plot a pixmap anywhere but in the core plot region.
In other words, when using the following code, and placing one coordinate inside and one coordinate outside the plot region, > library(pixmap) > logo<-read.pnm(system.file("pictures/logo.ppm", package="pixmap")) > source("/tmp/addlogo.R") > par(xpd=NA); plot(1:10); addlogo(x=c(2,4),y=c(9,11), pixmap=logo) > par(xpd=FALSE); plot(1:10); addlogo(x=c(2,4),y=c(9,11), pixmap=logo) > par(xpd=TRUE); plot(1:10); addlogo(x=c(2,4),y=c(9,11), pixmap=logo) all attempts result in a partial clipped pixmap (given the 1:10,1:10 plot region). Setting xpd inside addlogo()'s plot() made no difference. This was using this morning's alpha release of 1.8.0, and on Linux -- but it behaved the same on win2k with an older version of R. Am I misunderstanding something (which is most likely, given the still mysterious ways of ?par), or is this a bug in pixmap's plot method? Thanks, Dirk On Thu, Sep 18, 2003 at 03:24:32PM +0200, Roger Bivand wrote: > Gordon: > > This is a copy of an off-list reply from May 2003, which may give some > assistance - not quite the same, because here the image was inserted into > an existing plot. It is based on using the pixmap package to import a > ppm or pnm file, then rescaling to fit the designated space. > > Roger Bivand > > ---------- Forwarded message ---------- > Date: Mon, 26 May 2003 11:26:21 +0200 (CEST) > From: Roger Bivand <[EMAIL PROTECTED]> > To: [EMAIL PROTECTED] > Cc: > Subject: Re: [R] overlapping a plot with an external image > > > On Wednesday, May 21, 2003, at 04:38 PM, Prof Brian Ripley wrote: > > >> On Wed, 21 May 2003, Meinhard Ploner wrote: > > > >>> It's possible to overlap an external image (jpg or pdf) > >>> with a plot generated with R? > >> > >>> Specifying the image as the background > >>> of the plot might not be possible... > > > >> Although this has been discussed, R graphics devices cannot as yet plot > >> bitmap images. So all one can do is to plot a set of rectangles: for > >> that the pixmap package might be helpful. > > > >> Although we might add the ability to plot a bitmap image, note that it > >> is not straightforward, as R screen graphics devices can be dynamically > >> resized. What should be done with a plotted image then? Interpolate > >> on the fly? > > > The plotted image should be a logo of the project / department and I > > like to add it on every plot - for esthetical and descriptive reasons > > Here is a very rough addlogo() using pixmap: > > "addlogo" <- function(x, y, pixmap) { > if (is.list(x)) { > y <- x$y > x <- x$x > } > else if (missing(y)) > stop("missing y") > if (!is.numeric(x) || !is.numeric(y)) > stop("non-numeric coordinates") > if ((nx <- length(x)) <= 1 || nx != length(y) || nx > 2) > stop("invalid coordinate lengths") > [EMAIL PROTECTED] <- x[1] > [EMAIL PROTECTED] <- y[1] > [EMAIL PROTECTED] <- x[2] > [EMAIL PROTECTED] <- y[2] > [EMAIL PROTECTED] <- ([EMAIL PROTECTED] - [EMAIL PROTECTED]) / [EMAIL PROTECTED] > [EMAIL PROTECTED] <- ([EMAIL PROTECTED] - [EMAIL PROTECTED]) / [EMAIL PROTECTED] > plot(pixmap, add=TRUE) > invisible(pixmap) > } > > which will work with locator() too. To maintain aspect, it shouldn't alter > the relative cell resolutions, and should just use the new x or y, bur > this is the general case. The handling of the location of the logo is > copied & pasted from legend(). > > Roger > > -- > 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: [EMAIL PROTECTED] > > ______________________________________________ > [EMAIL PROTECTED] mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help > -- Those are my principles, and if you don't like them... well, I have others. -- Groucho Marx ______________________________________________ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help