1

I'm aware there are other posts on the same issue, but I couldn't use any to solve my specific problem.

I have this structured added to a ggplot object:

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

Moreover, I add this to set some elements to bold and change sizes (nevermind the different axis, there's a coord_flip() added to the ggplot structure as well).

 axis.text.y = element_text(face=c("plain", "plain", "plain", "bold", "plain", "plain", "bold", "plain", "plain", "plain", "bold", "plain"), 
                                        size=c(7.75, 7.75, 7.75, 9, 7.75, 7.75, 9, 7.75, 7.75, 7.75, 9, 7.75),
                                        hjust=0),

I'd also like for every bolded element to be underlined; I tried using the geom_label_repel but it kept running into a Error: Discrete value supplied to continuous scale problem.

vasili111
  • 6,032
  • 10
  • 50
  • 80
jpugliese
  • 261
  • 1
  • 11

1 Answers1

1

You can simply replace text, "text" with expression(~underline("text")) to underline. You might also want to add ~bold to get expression(~bold(~underline("text"))). In your case changing the scale line to:

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

should do the trick.

Mosquite
  • 588
  • 1
  • 4
  • 15