[R] lattice library: xyplot and polygons
Deepayan Sarkar
deepayansarkar at yahoo.com
Sun Mar 10 18:40:05 CET 2002
I haven't checked it out, but I'm pretty sure grid.polygon will work
if you add a default.units = "native" argument to it. Please let me know
if it doesn't, I'll take a closer look.
polygon will not work. I'll try to add a lpolygon along the lines of llines,
lpoints etc for the next release.
Deepayan
--- Renaud Lancelot <renaud.lancelot at cirad.fr> wrote:
> Dear R-Helpers,
>
> Is there a way to draw shaded (filled) polygons in panel graphs produced
> by xyplot ? I made different trials (see below) with polygon() and
> grid.polygon() but polygons are not drawn (probably for the same reason
> that prevents the use of lines, points, etc. in xyplot panels).
>
> Thanks in advance,
>
> Renaud
>
> > Asp <- diff(range(Water$longitude)) / diff(range(Water$latitude))
> > ### works but polygons are empty
> > xyplot(longitude ~ latitude,
> + data = Water, groups = id, aspect = Asp,
> + panel = function(x, y, ...){
> + panel.superpose(x, y, type = "l", col = 1,...)
> + })
> > ### does not work
> > xyplot(longitude ~ latitude,
> + data = Water, aspect = Asp,
> + panel = function(x, y){
> + for(i in unique(Water$id)){
> + cond <- Water$id == i
> + polygon(x = Water$latitude[cond], y = Water$longitude[cond],
> + border = "black", col = "light blue")
> + }
> + })
> > ### does not work
> > xyplot(longitude ~ latitude,
> + data = Water, aspect = Asp,
> + panel = function(x, y){
> + for(i in unique(Water$id)){
> + cond <- Water$id == i
> + grid.polygon(x = Water$latitude[cond],
> + y = Water$longitude[cond],
> + gp = gpar(col = "black", fill = "light blue"))
> + }
> + })
> >
>
> --
> Dr Renaud Lancelot, vétérinaire
> CIRAD, Département Elevage et Médecine Vétérinaire (CIRAD-Emvt)
> Programme Productions Animales
> http://www.cirad.fr/presentation/programmes/prod-ani.shtml
>
> ISRA-LNERV tel (221) 832 49 02
> BP 2057 Dakar-Hann fax (221) 821 18 79 (CIRAD)
> Senegal e-mail renaud.lancelot at cirad.fr
>
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
> Send "info", "help", or "[un]subscribe"
> (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
__________________________________________________
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list