[R] bubble plots

Deepayan Sarkar deepayan at stat.wisc.edu
Tue Sep 21 17:00:54 CEST 2004


On Tuesday 21 September 2004 08:41, Edzer Pebesma wrote:
> Jacques, please try the following:
>  > z=factor(c('a', 'b','c'))
>  > z
>
> [1] a b c
> Levels: a b c
>
>  > x = c(1,2,3)
>  > y = c(3,2,1)
>  > xyplot(y~x,groups=z,auto.key=T,asp=diff(range(y))/diff(range(x)))
>
> the asp argument takes care of one unit in x being equal to one unit
> in y. 

FWIW, In R 2.0.0 (currently beta), you can also do this with 
aspect="iso".

> If you add e.g. pch=z to vary symbols, auto.key will have to be 
> replaced by the more complex key argument, see ?xyplot

An alternative would be to change the settings (which is the only way 
the panel function and auto.key can share information). Temporary 
changes in settings can be attached to a trellis object as follows:

xyplot(y~x,groups=z,auto.key=T,asp=diff(range(y))/diff(range(x)),
       par.settings = 
       list(superpose.symbol = list(cex = 2, pch = levels(z))))

Deepayan




More information about the R-help mailing list