R 在缩放x连续标签的特定元素下划线

R 在缩放x连续标签的特定元素下划线,r,ggplot2,R,Ggplot2,我知道在同一个问题上也有,但我不能用任何方法来解决我的具体问题 我已将此结构化添加到ggplot对象: scale_x_continuous(breaks = c(1, 2.25, 3.5, 4.5, 5.5, 6.75, 7.75, 8.75, 10, 11.25, 12.25, 13.35), labels = rev(c("A", "B", "C", "D", "E", "F

我知道在同一个问题上也有,但我不能用任何方法来解决我的具体问题

我已将此结构化添加到ggplot对象:

scale_x_continuous(breaks = c(1, 2.25, 3.5, 4.5, 5.5, 6.75, 7.75, 8.75, 10, 11.25, 12.25, 13.35),
                     labels = rev(c("A", "B", "C", "D", 
                                    "E", "F", "G", "H",
                                    "I", "J", "K", "L")))
此外,我添加此选项是为了将某些元素设置为粗体并更改大小(无论轴是否不同,ggplot结构中也添加了
coord\u flip()


我还希望每一个粗体元素都加下划线;我尝试使用
geom\u标签\u repel
,但它一直遇到
错误:离散值提供给连续缩放问题。

您可以简单地用
表达式(~underline(“text”)
替换文本,
“text”
,以加下划线。您可能还需要添加
~bold
以获得
表达式(~bold(~underline(“text”))
。在您的情况下,将比例线更改为:

scale_x_continuous(breaks = c(1, 2.25, 3.5, 4.5, 5.5, 6.75, 7.75, 8.75, 10, 11.25, 12.25, 13.35),
                     labels = rev(c("A", expression(~underline("B")), "C", "D", 
                                    "E", expression(~bold(~underline("F"))), "G", "H",
                                    expression(~bold(~underline("I"))), "J", "K", "L")))
我们应该做到这一点

scale_x_continuous(breaks = c(1, 2.25, 3.5, 4.5, 5.5, 6.75, 7.75, 8.75, 10, 11.25, 12.25, 13.35),
                     labels = rev(c("A", expression(~underline("B")), "C", "D", 
                                    "E", expression(~bold(~underline("F"))), "G", "H",
                                    expression(~bold(~underline("I"))), "J", "K", "L")))