3

I'm putting together a lollipop plot that has a condition set on Var1 being greater than 1, where all the FALSE going to the left and are color coded in pink and all the TRUE go to the right of 1 and are color coded in blue.

I'd like to add labels next to the bubbles on the plot but I can only seem to be able to do so in one direction with the line geom_text(nudge_x=0.1). What can I add to place the value a little left of the pink bubbles and a little right of the blue bubbles?

Attaching the plot I currently have and here is the code I'm working with:

ggplot(data = data.in, aes(Var1, Var2, color = Condition, label = Total)) + 
  geom_segment(aes(x = 1, y = Var2, xend = Var1, yend = Var2), color = "grey50") +
  geom_vline(aes(xintercept = 1.00), color = "grey35", size = 1) +
  geom_point(size = 6) +
  geom_text(nudge_x = 0.1) +
  scale_x_continuous(breaks = c(0.20, 0.4, 0.6, 0.8, 1.0, 1.2, 1.4, 1.6, 
                                1.8, 2.0, 2.2, 2.4, 2.6, 2.8)) +
  labs(x = "Var1", y = "Var2") +
  theme(axis.text.x = element_text(size = 10, face = "bold"),
        axis.text.y = element_text(size = 9),
        axis.title.y = element_text(size = 12, face = "bold"),
        axis.title.x = element_text(size = 12, face = "bold"),
        legend.position = "none",
        panel.background = element_rect(fill = "white"),
        panel.grid.minor.y = element_line(colour = "grey87"),
        panel.grid.major = element_line(colour = "grey87"),
        plot.caption=element_text(size = 8))

Cheers!

lollipop

Z.Lin
  • 28,055
  • 6
  • 54
  • 94

0 Answers0