[R] Math Expression in 3D Plots

Duncan Murdoch murdoch at stats.uwo.ca
Fri Nov 21 12:21:01 CET 2008


Alan Lue wrote:
> Is there anyway to label axes in 3D plots with mathematical expressions?
>
> In the code below, I want to replace "delta_yrsed" with what "\Delta
> \widehat{yrsed}" represents in TeX, but the [xyz]lab parameters of title3d
> appear to only accept character strings.
>   

Unfortunately, that's right:   rgl doesn't have any support for plotmath 
type text. 

The only way to get what you want would be to produce bitmaps of the 
labels, then place those in the plots as sprites or surface textures.

Duncan Murdoch
> require("rgl")
>
> fn.delta.yrsed <- function(dist, delta.dist,
>                            beta.dist=-0.1376463, beta.dist2=0.0088698) {
>   delta.yrsed <- (beta.dist + 2*beta.dist2*dist)*delta.dist +
> beta.dist2*delta.dist^2
>   return(delta.yrsed)
> }
>
> plot.deeffect <- function(scolor="blue") {
>   delta.dist <- dist <- seq(0, 16, .5)
>   delta.yrsed <- outer(dist, delta.dist, fn.delta.yrsed)
>
>   rgl.open()
>   bbox3d(xat=seq(0, 16, 2), yat=0:5, zat=seq(0, 16, 2), color="black")
>   title3d(main="Effect of Change in dist on yrsed",
>           pos=c(NA, 8, 0), color="black")
>   title3d(xlab="dist", pos=c(NA, 0, -3), color="black")
>   title3d(ylab="delta_yrsed", pos=c(12, NA, -3), color="black")
>   title3d(zlab="delta_dist", pos=c(-3, 0, NA), color="black")
>   rgl.bg(color=rep("white", 2))
>   rgl.surface(dist, delta.dist, delta.yrsed,
>               color=scolor, front="lines", back="lines")
> }
>
> Alan
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list