I am making qq plots of my data and found ggqqplot, which adds the line and the confidence intervals. I have stable isotope data and ultimately want my y-axis label to show: Sample δ13C Values.
since just working with the label, dataset does not matter - got this off the web
# Create some data
set.seed(1234)
wdata = data.frame(
sex = factor(rep(c("F", "M"), each=200)),
weight = c(rnorm(200, 55), rnorm(200, 58)))
head(wdata, 4)
# no italics no superscript
ggqqplot(wdata,
x = "weight",
title = NULL,
xlab = NULL,
ylab = "Sample \u03B413C Values"
)
#tried bquote with ^ for superscript -unicode not recognized, tried delta
#https://stackoverflow.com/questions/63010394/superscript-in-axis-labels-in-ggplot2-for-ions
#produces Error in `map()`: ℹ In index: 5. ℹ With name: ylab. Caused by error in `.f()`: ! argument "user_env" is missing, with no default
ggqqplot(wdata,
x = "weight",
title = NULL,
xlab = NULL,
ylab = bquote("Sample"~delta^{13}*"C Values"))
# tried expression with ^ for superscript -> produces error unexpected '^'
#(https://stackoverflow.com/questions/69212413/super-script-within-axis-label-using-ggplot2-or-ggpubr)
ggqqplot(wdata,
x = "weight",
title = NULL,
xlab = NULL,
ylab = expression("Sample \u03B4"*^13*"C Values")
)
#tried just getting plain and italic text
#https://stackoverflow.com/questions/72538196/r-ggpubr-ggplot2-use-italics-for-one-factor-level
#produces Error in `map()`: ℹ In index: 5. ℹ With name: ylab. Caused by error in `.f()`: ! argument "user_env" is missing, with no default
ggqqplot(wdata,
x = "weight",
title = NULL,
xlab = NULL,
ylab = expression(plain("Sample")~italic("\u03B4")~plain("13C Values"))
)
#tried using bquote and ylab as vector
#https://stackoverflow.com/questions/4973898/combining-paste-and-expression-functions-in-plot-labels
#produces Error in `map()`: ℹ In index: 5. ℹ With name: ylab. Caused by error in `.f()`: ! argument "user_env" is missing, with no default
ylab <- bquote("Sample"~delta^13*"C Values")
ggqqplot(wdata,
x = "weight",
title = NULL,
xlab = NULL,
ylab = ylab
)
Instead of using the ylab
argument you could add your y axis label with ggplot2::labs()
:
library(ggpubr)
ggqqplot(wdata,
x = "weight",
title = NULL,
xlab = NULL
) +
labs(y = bquote("Sample"~delta^{13}*"C Values"))