By Jochen Voss, on
For (my own) future reference, here are example commands to create a 3D (surface) plot in R:
library("rgl") open3d(windowRect=c(50,50,800,800)) x <- seq(-10, 10, length=20) y <- seq(-10, 10, length=20) z <- outer(x,y, function(x,y) dnorm(x, 2, 3)*dnorm(y, 3, 7)) palette <- colorRampPalette(c("blue", "green", "yellow", "red")) col.table <- palette(256) col.ind <- cut(z, 256) persp3d(x, y, z, col=col.table[col.ind])
These commands open the plot in a new window. The
windowRect parameter in the call to
determines the initial position and size of the window (many thanks to Jem
Corcoran for pointing this out). The output can be rotated and scaled
using the mouse.
This is an excerpt from Jochen's blog.
Newer entry: Police and Crime Commissioner elections
Older entry: publication-quality figures with R, part 2
Copyright © 2012, Jochen Voss. All content on this website (including text, pictures, and any other original works), unless otherwise noted, is licensed under a Creative Commons Attribution-Share Alike 3.0 License.