I am generating a bunch of plots and have stored the appropriate labels for axes in my plots in a list:
labels_list <- c("C[max,1] (mg/L)", "AUC[
6wks,1 ] (mg*day/L)", "somethingElse[subscriptText] (units*might/have*symbols)")
My goal is to create labels where the text in the square brackets are subscripts. I have been using parse()
which is okay, except:
I know that bquote()
is an option, but I haven't figured out how to use it if I just want to provide a list of strings as inputs like above. I'm definitely open to any suggestions and solutions provided.
EDIT: It seems that I cannot use my string inputs as-is? labels_list
is extracted from a data frame and I would love to not have to, one-by-one, change this for plotting purposes. :-(
Here's an approach with expression
and bold
:
labels_list <- c(expression(bold(C[max * ',' * 1]~(mg/L))),
expression(bold(AUC["6wks"*','*1]~(mg * '*' * day/L))),
expression(bold(somethingElse[subscriptText]~(units * '*' * might/have * '*' *symbols))))
ggplot(data = data.frame(x = 1, y = 1), aes(x,y)) +
geom_point() +
labs(x = labels_list[1], y = labels_list[2], caption = labels_list[3])
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.