问题
I am talking about this picture:
![](https://www.eimg.top/images/2020/03/25/aa0fb4e746ce149d5c8c84eb4ab1a5b0.png)
Questions:
This is R, not Matlab right? Below the page it says it was made with R....
How can I do this? I mean, how can I create such a 3d scatterplot with this advanced green surface and this grid? I now how to make simple scatterplots and also 3d scatterplots, but how can I create such an advanced picture? Which package is this?
I want to include it in a paper where this picture should rotate automatically. I know how to include this into my tex-distribution, but therefore I need single png. So e.g. 1000 single pictures which I animate. But how can I get those with R? I would need to rotate it and then save every single small rotation as a graphic file.
Thanks a lot for your help, my biggest problems are the creation of this graphic (packages?) and how to make it rotate (r code?)
回答1:
To create this figure, you might check out
persp
function. You can change the parameter to rotate the figure. Here's one demo:require(grDevices) # for trans3d x <- seq(-10, 10, length= 30) y <- x f <- function(x,y) { r <- sqrt(x^2+y^2); 10 * sin(r)/r } z <- outer(x, y, f) z[is.na(z)] <- 1 persp(x, y, z, theta = 90, phi = 30, expand = 0.5, col = "lightgreen")
![](https://i0.wp.com/i.stack.imgur.com/lJXzE.png)
When change theta = 30
:
persp(x, y, z, theta = 30, phi = 30, expand = 0.5, col = "lightgreen")
![](https://i0.wp.com/i.stack.imgur.com/moImf.png)
- For color, you can type
colors()
to see what color you can use. Currently, I foundlightgreen
might be the closest color you want.
来源:https://stackoverflow.com/questions/13387119/how-can-i-recreate-this-3d-histogram