[R-sig-Geo] Add coastline to an existing xyplot [SEC=UNCLASSIFIED]

Felix Andrews felix at nfrac.org
Fri Nov 2 03:26:32 CET 2007


plot() is a base graphics function. You can not use it in a Lattice
context. And also you can not add to a Lattice plot as you tried to
do: you need to use a panel function, or call trellis.focus(). I
suggest you read the Lattice documentation.

This is one way to do it:

library(sp)

xyplot(lat ~ long, data=mud, panel=function(...) {
sp.polygons(coastline)
panel.xyplot(...)
},
asp="iso", type="p", pch=1, cex=0.01, xlab="", ylab="")



On 11/2/07, Jin.Li at ga.gov.au <Jin.Li at ga.gov.au> wrote:
> Hi there,
>
> I tried to add a coastline that is imported from a shapefile to a xyplot of
> sample points, but I got an error message.
>
>
>
> > library(lattice)
>
> > library(maptools)
>
> > xyplot(mud$lat~mud$long, asp="iso", type="p", pch=1, cex=0.01, xlab="",
> ylab="")
>
> >
>
> > plot(coastline, add=T)
>
> Error in plot.xy(xy.coords(x, y), type = type, ...) :
>
>         plot.new has not been called yet
>
> >
>
> I also tried using plot.new=TRUE in the xyplot and got the same message.
>
>
>
> I could get a plot from only using plot(coastline),  but could not add it to
> the existing xyplot.
>
>
>
> Thanks in advance.
>
> Jin
>
>
>
>
>         [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>


-- 
Felix Andrews / 安福立
PhD candidate
Integrated Catchment Assessment and Management Centre
The Fenner School of Environment and Society
The Australian National University (Building 48A), ACT 0200
Beijing Bag, Locked Bag 40, Kingston ACT 2604
http://www.neurofractal.org/felix/
3358 543D AAC6 22C2 D336  80D9 360B 72DD 3E4C F5D8




More information about the R-sig-Geo mailing list