geom_label with custom background and color (text)

Hi @mutuelinvestor. You may custom the color of fill and color by scale_fill_manual and scale_color_manual like the following code.

library(tidyverse)

df <- data.frame(x = sample(1:50, 5), y = sample(1:50, 5), group = LETTERS[1:5], stringsAsFactors = FALSE)

df %>%
  ggplot(aes(x = x, y = y)) +
  geom_point() +
  geom_label(aes(label = group, fill = group, color = group), size = 2.5) +
  ggConvexHull::geom_convexhull(alpha = 0.2, fill = "blue") +
  scale_fill_manual(values = RColorBrewer::brewer.pal(5, "Spectral")) +
  scale_color_manual(values = rev(RColorBrewer::brewer.pal(5, "Spectral")))

Created on 2019-11-20 by the reprex package (v0.3.0)

2 Likes