Publication: Sampling Conditioned Hypoelliptic Diffusions. Construction of fourth-order SPDEs which are invariant with respect to the distribution of hypoelliptic diffusion processes, subject to a bridge conditioning. … read more

Blog: Watching DVDs on an Apple iPad. How to transfer a movie from a DVD onto an Apple iPad? … read more

Blog: LaTeX: calling a macro for every line of input. How to call a LaTeX macro for every line in an environment? … read more

3D graphics in R (updated)

By , on [atom feed]

For (my own) future reference, here are example commands to create a 3D (surface) plot in R:


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 open3d 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.

[a 3D plot, generated with R]

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.