I'm having a lot of problems creating a legend for a bar plot in ggplot2.
The plot is fine, but the legend writes all the labels as if they were Python's tuples (i.e. (id1, 1, NA) ). I cannot explain why this is happening since that's not how they are written in the data and I'm having a hard time modifying them.
Has anybody seen this behavior before? How could I fix it?
data_filtered <- data.table(date = seq(as.Date('01-01-2020'), as.Date('10-01-2020'), by = '1 day'), filling = 1:10, idForLegend = c('id1', 'id2', 'id3', 'id4', 'id5', 'id6', 'id7', 'id8', 'id9', 'id10')) p <- data_filtered %>% ggplot(aes(x = date, fill = idForLegend, y = filling)) + geom_bar(position = "dodge", stat = 'identity') + geom_hline(aes(yintercept = 5, linetype = 'Filling Threshold'), color='red', size=0.4) + theme_ipsum( grid = FALSE, caption_margin = 1, subtitle_margin = 1, plot_title_margin = 1, plot_margin = margin(1, 1, 1, 1) ) + scale_color_manual(values = data_filtered$idForLegend) + #scale_color_manual(name = "Legend", labels = c('Filling Threshold', unique(data_filtered$idForLegend))) + scale_fill_brewer(palette="Paired")