本文介绍了显示大于等于号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  ggplot(dt.2,aes(x = AgeGroup,y =流行度))+ 
geom_errorbar(aes(ymin = lower,ymax = upper),color =black,width = 0.2)+
geom_point(size = 2,color =Red)

我控制x轴标签,如下所示:

  scale_x_discrete(标签= C( 0-29, 30-49, 50-64, 65-79, > 80, 全部 ))+ 

这可行,但我需要将> 80标签更改为≥80 。



然而,≥80显示为= 80。



如何显示大于等号?

解决方案

使用表达式的替代方法是Unicode字符,在这种情况下,Unicode字符'大于或等于'(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))

如果您无法记住复杂的表达式语法,如果你需要换行符,哪些表达式不允许。作为缺点,特定的Unicode字符是否完全取决于您的图形设备和选择的字体。


I have a plot which is generated thus:

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

I control the x axis labels like this:

scale_x_discrete(labels=c("0-29","30-49","50-64","65-79",">80","All")) +

This works but I need to change the ">80" label to "≥80".

However "≥80" is displayed as "=80".

How can I display the greater than or equal sign ?

解决方案

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.

这篇关于显示大于等于号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-29 06:00