[R-sig-Geo] Marginless plot output for georegistration of output graphics
David Forrest
drf5n at maplepark.com
Tue Jan 16 19:06:33 CET 2007
On Thu, 11 Jan 2007, Roger Bivand wrote:
> On Thu, 11 Jan 2007, David Forrest wrote:
>
>> Hi All,
...
I think I can make marginless plots in base, lattice, and sp graphics now,
but I'm still missing something about the data ranges for spplot.
#################################
# Marginless plots in base graphics:
library(stats)
par.save<-par(no.readonly = TRUE);
par(mar=c(0,0,0,0))
plot(quakes$long,quakes$lat,xaxs='i',yaxs='i',xlab=FALSE,axes=FALSE)
par(par.save)
########### in lattice/trellis/grid
library(lattice)
theme.novpadding <-
# From Deepayan Sarkar's posting of 2006-10-12:
list(layout.heights =
list(top.padding = 0,
main.key.padding = 0,
key.axis.padding = 0,
axis.xlab.padding = 0,
xlab.key.padding = 0,
key.sub.padding = 0,
bottom.padding = 0),
layout.widths =
list(left.padding = 0,
key.ylab.padding = 0,
ylab.axis.padding = 0,
axis.key.padding = 0,
right.padding = 0))
print( # lattice/grid With device extents == data extents
xyplot(lat ~ long , data=quakes, pch=".",
,xlab=NULL,ylab=NULL
,scales=list(axs='i',draw=FALSE)
,par.settings=theme.novpadding))
######### In spatial (with internal & device margin)
# An example of a marginless plot in library(sp)
library(sp)
qk<-SpatialPointsDataFrame(quakes[,c(2:1)],quakes)
proj4string(qk)<-CRS("+proj=longlat")
spplot(qk,'mag',key.space=list(x=0.25,y=.2,corner=c(1,1)),
par.settings=theme.novpadding,scales=list(axs='i',draw=FALSE))
#####################
The device/aspect ratio margin is controllable and manageable with a
mapasp(gk) based device call.
I'd still like to eliminate the remaining internal margin from around the
plot. I saw it once in my experimenting, but I am not sure if it was some
interaction with par() or something and have not able to duplicate
it.
Dave
--
Dr. David Forrest
drf at vims.edu (804)684-7900w
drf5n at maplepark.com (804)642-0662h
http://maplepark.com/~drf5n/
More information about the R-sig-Geo
mailing list