> xlabel <- expression(paste(Delta, italic(s), sep = ""))
> ylabel <- expression(alpha[1] * " in (kg)"^2)
> plotname <- expression(sin * (beta))
> plot(rnorm(50), rnorm(50), xlab = xlabel, ylab = ylabel, main = plotname, xlim = c(-pi, pi), ylim = c(-3, 3), axes = FALSE)
> axis(1, at = c(-pi, -pi/2, 0, pi/2, pi), labels = expression(-pi, -pi/2, 0, pi/2, pi))
> axis(2)
> box()
> box()
> text(-pi/2, -2, expression(hat(beta) == (X^t * X)^{-1} * X^t * y))
> text(pi/2, 2, expression(paste(frac(1, sigma*sqrt(2*pi)), exp*(frac(-(x-mu)^2, 2*sigma^2)), sep = "")), cex = 1.5)
If you want to know more about expression and putting math symbols on the plot, run the following demos in R.
> demo(plotmath)
No comments:
Post a Comment