简体   繁体   中英

Legend label in ggplot2

What I'm missing here? Not getting proper legend label.

p <- ggplot(mtcars, aes(factor(cyl), mpg))+ geom_boxplot(aes(fill = cyl))
p <- p + labs(fill=expression(paste("Temperature\n (", degree ~ F, " )")))
p

在此输入图像描述

I do not see any need to use plotmath-paste:

 p <- ggplot(mtcars, aes(factor(cyl), mpg))+ geom_boxplot(aes(fill = cyl))
 p <- p + labs(fill=expression(atop("Temperature", ( degree~F))))
 p

Plus the help(plotmath) page makes clear that "\\n" does not play well with expressions.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM