I want my plot to have the colors I defined in ‘r’, but after executing ‘scale_color_discrete’ to rename the samples in the legend, the colors in the plot become different from the ones I chose.
my code:
r = c ("darkgrey", "black", '#F49E4C', "#BF1A2F" , "mediumpurple" , "#FFFD82" , "#94C9A9" , "palevioletred1" , "steelblue2")
ggplot(curva, aes(x = Time, y = (Absorbance_Mean), color =
Sample, fill = Sample))+
geom_line(size = 0.8)+
scale_color_manual(values = r) +
theme_classic() +
scale_y_continuous(trans = 'log',
breaks = c(0.05, 0.1, 0.3, 0,5))
ylab("Log10 OD600") +
scale_color_manual(values = r) +
xlab("Time (h)") +
facet_wrap(~ Condition, ncol = 2) +
theme(
legend.position = "bottom",
legend.text = element_text(size = 13),
strip.background = element_blank(),
panel.border = element_rect(fill = NA, color = "black"),
scale_color_discrete(breaks = c ("COLI", "KT2440", "SA1", "SA3", "SA6", "SB1", "WA1", "WA3", "WA5"),labels= c ("E. coli" , "P. putida" , "Bacillus sp 1" , "Bacillus sp. (S3)" , "B. subtilis" , "Priestia sp." , "Bacillus sp. (W1)" , "P. megaterium (W5)" , "Bacillus sp. (W3)"))
I tried changing the layer “scale_manual”, but it doesn’t work, I hope I can solve my problem and have the legend renamed with the colors I want
New contributor
Camila Marques is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.