I found a problem with geom_label() in ggplot2 v3.5.1.
I expected that setting label.colour = "black" would change the text colour inside the label, as described in the documentation. Instead, I get the warning: Ignoring unknown parameters: label.colour and the text colour is not changed.
Here is the code to reproduce the bug:
library(ggplot2)
df <- data.frame(
data = c("A", "B"),
pos_y = c(1, 2),
rank = c(1, 2)
)
ggplot(df, aes(x = data, y = pos_y)) +
geom_label(
aes(label = rank, colour = data),
label.colour = "black",
size = 4,
vjust = 1
) +
scale_colour_manual(values = c("red", "blue"))
Expected:
The border of the label should follow the colour mapping (colour = data). The text inside the label should be black (label.colour = "black").
Actual:
The border and text both follow the colour mapping, and the warning about label.colour appears.