Skip to content

Instantly share code, notes, and snippets.

@mages
Created July 4, 2015 16:58
Show Gist options
  • Save mages/62513539267b515d8190 to your computer and use it in GitHub Desktop.
Save mages/62513539267b515d8190 to your computer and use it in GitHub Desktop.
library(latex2exp)
x <- seq(-4, 4, len = 101)
y <- cbind(sin(x), cos(x))
op=par(mfrow=c(2,1))
## plotmath
matplot(x, y, type = "l", xaxt = "n",
main = expression(paste("plotmath: ", plain(sin) * phi, " and ",
plain(cos) * phi)),
ylab = expression("sin" * phi, "cos" * phi), # only 1st is taken
xlab = expression(paste("Phase Angle ", phi)),
col.main = "blue")
axis(1, at = c(-pi, -pi/2, 0, pi/2, pi),
labels = expression(-pi, -pi/2, 0, pi/2, pi))
## latex2exp
matplot(x, y, type = "l", xaxt = "n",
main = latex2exp("latex2exp: $\\sin \\phi$ and $\\cos \\phi$"),
ylab = latex2exp("$\\sin \\phi$ and $\\cos \\phi$"),
xlab = latex2exp("Phase Angle $\\phi$"),
col.main = "blue")
axis(1, at = c(-pi, -pi/2, 0, pi/2, pi),
labels = sapply(c("$-\\pi$", "$-\\pi/2$",
"0", "$\\pi/2$", "$\\pi$"),
latex2exp))
par(op)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment