我想在刻面标签中有expression
一个ggplot2
R。
假设我正在绘制tips
data.frame
:
library(reshape2)
> head(tips)
total_bill tip sex smoker day time size
1 16.99 1.01 Female No Sun Dinner 2
2 10.34 1.66 Male No Sun Dinner 3
3 21.01 3.50 Male No Sun Dinner 3
4 23.68 3.31 Male No Sun Dinner 2
5 24.59 3.61 Female No Sun Dinner 4
6 25.29 4.71 Male No Sun Dinner 4
如下:
library(ggplot2)
sp <- ggplot(tips, aes(x=total_bill, y=tip/total_bill)) +
geom_point(shape=1) +
facet_wrap(~sex, ncol = 1)
我不想将“女性”和“男性”作为分面标签,而是分别使用:“女性主题”和“男性主题”。据我所知,在 R 中将标签斜体化是通过该expression
函数实现的,但我不知道如何将其与facet_wrap
.