How can I recreate this 3d histogram?

若如初见. 提交于 2019-12-24 15:04:00

问题


I am talking about this picture:

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:


  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")
    

When change theta = 30:

persp(x, y, z, theta = 30, phi = 30, expand = 0.5, col = "lightgreen")

  1. For color, you can type colors() to see what color you can use. Currently, I found lightgreen might be the closest color you want.


来源:https://stackoverflow.com/questions/13387119/how-can-i-recreate-this-3d-histogram

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!