Sorry if this is a silly question, but consider this simple example
tibble(type = c('a','b','c'), x = c(1,2,3), y = c(10,0,10)) %>% ggplot(aes(x, y , color = type)) + geom_point()+ scale_color_discrete(labels = c('hello','world','!!!'))
As you can see, I am renaming the legend with
However, I am not sure I understand what is the exact mapping here. Are the labels applied to
type is sorted alphabetically? That is,
hello replaces whatever value is first when
type is sorted (that is
a in this case)? What about weird other situations?
Is there a more robust way to do so? For instance by specifying a list like
list(old_label = new_label) so that there is no ambiguity in the labeling?
Does that make sense?