Created
July 4, 2015 16:58
-
-
Save mages/62513539267b515d8190 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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