Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLOUD #33

Open
junjunlab opened this issue Sep 16, 2023 · 5 comments
Open

CLOUD #33

junjunlab opened this issue Sep 16, 2023 · 5 comments

Comments

@junjunlab
Copy link

No description provided.

@junjunlab
Copy link
Author

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!

@m-jahn
Copy link

m-jahn commented Sep 18, 2023

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?

@junjunlab
Copy link
Author

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:
1695019872055

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:
1695020152475

@m-jahn
Copy link

m-jahn commented Sep 18, 2023

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
)

image

That doesn't fix the legend though, you might have to add one by hand.

@junjunlab
Copy link
Author

Thanks for your help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants