Re: [R] Math Expression in 3D Plots

From: Duncan Murdoch <murdoch_at_stats.uwo.ca>
Date: Fri, 21 Nov 2008 06:21:01 -0500

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



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. Received on Fri 21 Nov 2008 - 11:24:22 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 21 Nov 2008 - 13:30:26 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive