Rob*_*ong 38 r ggplot2 plotmath
我有一个由此产生的情节:
ggplot(dt.2, aes(x=AgeGroup, y=Prevalence)) +
geom_errorbar(aes(ymin=lower, ymax=upper), colour="black", width=.2) +
geom_point(size=2, colour="Red")
Run Code Online (Sandbox Code Playgroud)
我像这样控制x轴标签:
scale_x_discrete(labels=c("0-29","30-49","50-64","65-79",">80","All")) +
Run Code Online (Sandbox Code Playgroud)
这有效,但我需要将"> 80"标签更改为"≥80".
但是"≥80"显示为"= 80".
如何显示大于或等号?
ots*_*saw 37
使用表达式的替代方法是Unicode字符,在这种情况下,Unicode字符'GREATER-THAN OR EQUAL TO'(U + 2265).复制@ mnel的例子
.d <- data.frame(a = letters[1:6], y = 1:6)
ggplot(.d, aes(x=a,y=y)) + geom_point() +
scale_x_discrete(labels = c(letters[1:5], "\u2265 80"))
Run Code Online (Sandbox Code Playgroud)
如果您无法记住复杂的表达式语法或者需要换行符(表达式不允许),则Unicode是一个不错的选择.作为缺点,特定的Unicode字符是否起作用取决于您的图形设备和选择的字体.
mne*_*nel 21
你可以传递一个表达式(包括在参数中phantom(...)伪造一个前导>=labelscale_x_discrete(...)
例如
.d <- data.frame(a = letters[1:6], y = 1:6)
ggplot(.x, aes(x=a,y=y)) + geom_point() +
scale_x_discrete(labels = c(letters[1:5], expression(phantom(x) >=80))
Run Code Online (Sandbox Code Playgroud)

有关?plotmath创建数学表达式和此 相关SO问题和答案的更多详细信息,
请参阅
| 归档时间: |
|
| 查看次数: |
43172 次 |
| 最近记录: |