I have produced a nice Likert-style plot below. I've put labels on segments to enhance clarity. However, I would like the labels to be white on dark background and black on light background. How can I accomplish that?
I tried setting the additional dummy with zeros for all variables for which I would like to have black data-labels and ones for all variables for which I'd like to have white data-labels. Then I added parameter color = dummy to geom_text_repel. Although the labels have correct color, the segments change color with a bad result.
My code below:
color_palette = c("#525199", "#9393C6", "#A8A8A8","#FFA166", 
                  "#FF6200", "#FFFFFF", "#000000")
title <- "If you were to buy a car, would you choose...?"
subtitle <- "Subtitle"
# basic plot
p <- dane_3long %>% 
  ggplot() +
  geom_segment(aes(x = pytanie, y = start, xend = pytanie, 
                   yend = start + value, colour = variable), 
               size = 8) +
  scale_color_manual("", 
                     labels = c("1 - definitely no", "2", "3", "4", "5 - definitely yes"), 
                     values = ING_Likert_palette, guide = "legend") +
  coord_flip() +
  geom_hline(yintercept = 0, color =c("#A8A8A8"))
# Below I create labels 
p <- p + geom_text(aes(label = scales::percent(round((value), digits = 2)), 
                       colour = dummy, x = pytanie, y = (start + value)-value/2), 
                   size = 3, family = "ING Me") +
  theme_classic() +
  scale_y_continuous(breaks = seq(- 75, 75, 25), limits=c(- 0.73, 0.7))
# Below is styling of the plot
p <- p + labs(title = title, 
              subtitle = subtitle, 
              caption = "Źródło: Barometr finansowy ING", 
              y= " Percent", x= "") +
  theme(plot.title = element_text(face = "bold", size = 12),
        plot.subtitle = element_text(size = 9),
        plot.caption = element_text(size = 7, face = "italic"),
        legend.position = "right",
        legend.text = element_text(family = "ING Me",
                                   size = 8,
                                   color = grey(.3)),
        axis.title.x = element_blank(),
        axis.title.y = element_blank(),
        axis.line = element_blank(),
        axis.ticks = element_blank(),
        axis.text.x = element_blank(),
        text = element_text(family = "ING Me",
                            size = 14,
                            color = grey(.3))); p


 
    