Re: [R] LaTeX Notations in R output graphs

From: Thomas Lumley <tlumley_at_u.washington.edu>
Date: Tue 30 Aug 2005 - 00:31:16 EST

On Mon, 29 Aug 2005 depire@inrets.fr wrote:

> Hello,
> I'm interested in LaTeX notations in R graphs. For example, I would like to know
> the R code to obtain the graph here,
> http://www.r-project.org/screenshots/power.png

Here is the code:

x<-seq(-10,10,length=400)

y1<-dnorm(x)
y2<-dnorm(x,m=3)
par(mar=c(5,4,2,1))
plot(x, y2, xlim=c(-3,8), type="n", xlab=quote(Z==frac(mu[1]-mu[2],
                 sigma/sqrt(n))), ylab="Density")
polygon(c(1.96,1.96,x[240:400],10), c(0,dnorm(1.96,m=3),y2[240:400],0),
                 col="grey80", lty=0)

lines(x, y2)
lines(x, y1)
polygon(c(-1.96,-1.96,x[161:1],-10), c(0,dnorm(-1.96,m=0), y1[161:1],0),
                 col="grey30", lty=0)
polygon(c(1.96, 1.96, x[240:400], 10), c(0,dnorm(1.96,m=0),
                 y1[240:400],0), col="grey30")
legend(4.2, .4, fill=c("grey80","grey30"),
              legend=expression(P(abs(Z)>1.96, H[1])==0.85,
              P(abs(Z)>1.96,H[0])==0.05), bty="n")
text(0, .2, quote(H[0]:~~mu[1]==mu[2]))
text(3, .2, quote(H[1]:~~mu[1]==mu[2]+delta))

R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Tue Aug 30 00:37:27 2005

This archive was generated by hypermail 2.1.8 : Sun 23 Oct 2005 - 16:01:58 EST