Displaying a greater than or equal sign

旧城冷巷雨未停 提交于 2019-11-27 04:21:47

An alternative to using expressions is Unicode characters, in this case Unicode Character 'GREATER-THAN OR EQUAL TO' (U+2265). Copying @mnel's example

.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"))

Unicode is a good alternative if you have trouble remembering the complicated expression syntax or if you need linebreaks, which expressions don't allow. As a downside, whether specific Unicode characters work at all depends on your graphics device and font of choice.

mnel

You can pass an expression (including phantom(...) to fake a leading >= within the label argument to scale_x_discrete(...)

for example

 .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))

See ?plotmath for more details on creating mathematical expressions and this related SO question and answer

plot(5, ylab=expression("T ">="5"))

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!