[R] cloud() 3D scatter plot

Deepayan Sarkar deepayan.sarkar at gmail.com
Sat Dec 3 00:54:45 CET 2005


On 12/2/05, Michelle DePrenger-Levin <DePrengM at botanicgardens.org> wrote:
> Hello,
>
> I am creating a 3D scatter plot with the cloud function. I ask it to
> group my rows by a "Treatment" column (there are 4 different groups). I
> need to know which points in the plot correspond to which rows (which
> treatment). By default it assigns pchs and cols to each group. When I
> try to define the colors or point shapes it seems to use the first color
> and pch for both the first and last group. I've tried to add:
>
> col = c("blue","red","orange","green"),
> pch = c(20,20,22,22),
>
> after the "cex" line.

It's difficult to say without a reproducible example. The following
works as expected for me:

g <- gl(4, 50)
mu <- 2 * as.numeric(g)
x <- rnorm(200, mean = mu)
y <- rnorm(200, mean = mu)
z <- rnorm(200, mean = mu)

cloud(z ~ x * y, groups = g,
      col = c("blue", "red", "orange", "green"),
      pch = c(20, 20, 22, 22))

The only explanation I can think of is that your grouping variable has
more than 4 levels. What does

table(RMM$Treatment)

give you? Although, that doesn't explain why cex would work.

-Deepayan

> The only think that seems to work and keep all four groups separate is
> making
>
> cex = c(1,2,3,4),
>
> I cannot figure out what it combines the first and last of my groups
> with the same point character and color. Any suggestions?
>
> (Part of my code)
> ....
> print(cloud(RMMdistMETAc3$points[,1] ~ RMMdistMETAc3$points[,2] *
> RMMdistMETAc3$points[,3],
>             data = RMM,
>             cex = 0.8,
>   	
>             groups = Treatment,
>             screen = list(z = 10, x = -40, y = 3),
>             ) .....




More information about the R-help mailing list