Open junjunlab opened 1 year ago
Can you provide a reproducible code example of what you have tried so far, and how the desired output should look like? Basically you can provide any column as input for lattice xyplot() family functions, the names do not matter. What is the cloud function, what does it do?
Hi, this is my code
head(test)
# x y z exp
# 1 -6.200109 10.289067 3.757442 5.906180
# 2 -5.049636 12.015050 4.681233 5.808236
# 3 -4.850931 12.939070 4.725414 5.505874
# 4 -4.681532 13.571788 5.314072 5.157969
# 5 -2.249254 -4.712174 -3.898490 5.092196
# 6 -6.240337 10.407148 3.735936 5.028449
cloud(z ~ x*y,data = test,
drape = T,colorkey = T)
and the plot:
I want to change the points colors according to exp range, and the colorbar seems not right. What should I do to achive this? Thanks for your reply!
The following plot is what I want:
Hey, now I see what you mean. One option is to use the groups
argument to color-code your points.
However, this is more suitable for categories / factors, not really for continuous variables as in your case. But if you cut
(bin) your data into a discrete variable, you can use it like this:
test = data.frame(x = rnorm(100), y = rnorm(100), z = rnorm(100))
test$val = with(test, x + y + z)
cloud(z ~ x * y,
data = test,
groups = cut(val, 5),
pch = 19,
auto.key = TRUE
)
That doesn't fix the legend though, you might have to add one by hand.
Thanks for your help!
Hi, thanks for developing this great tool. I want to plot 3D scatter plot and map the point colors with another column(not in x,y,z), how should I use the cloud function to create this and add a color bar beside the plot. Tnanks for your reply!