我正在做一个R图,并希望对每组数据以不同的颜色显示。为此,我正在使用scale_color_manual()
。这东西在前九个或十个曲线上都可以正常工作,但是在后两个曲线中,ggplot不会设置我选择的颜色。
我将代码放在这里,并复制一份我得到的剧情,以便您可以了解我在说什么。由于有很多不同的数据集,因此我不会在此处发布,但问题出在最后两条曲线上,分别为“SaídaR11”和“SaídaR12”。
ggplot() +
geom_point(data = C1D1, mapping = aes(x <- V2, y = V1V2/R, colour = "Saída R1"), size = a) +
geom_point(data = C1D2, mapping = aes(x <- V2, y = V1V2/R, colour = "Saída R2"), size = a) +
geom_point(data = C1D3, mapping = aes(x <- V2, y = V1V2/R, colour = "Saída R3"), size = a) +
geom_point(data = C1D4, mapping = aes(x <- V2, y = V1V2/R, colour = "Saída R4"), size = a) +
geom_point(data = C1D5, mapping = aes(x <- V2, y = V1V2/R, colour = "Saída R5"), size = a) +
geom_point(data = C1D6, mapping = aes(x <- V2, y = V1V2/R, colour = "Saída R6"), size = a) +
geom_point(data = C1D7, mapping = aes(x <- V2, y = V1V2/R, colour = "Saída R7"), size = a) +
geom_point(data = C1D8, mapping = aes(x <- V2, y = V1V2/R, colour = "Saída R8"), size = a) +
geom_point(data = C1D9, mapping = aes(x <- V2, y = V1V2/R, colour = "Saída R9"), size = a) +
geom_point(data = C1D10, mapping = aes(x <- V2, y = V1V2/R, colour = "Saída R10"), size = a) +
geom_point(data = C1D11, mapping = aes(x <- V2, y = V1V2/R, colour = "Saída R11"), size = a) +
geom_point(data = C1D12, mapping = aes(x <- V2, y = V1V2/R, colour = "Saída R12"), size = a) +
annotate("rect", fill = "#D1C5CF", alpha = 0.4, xmin = -0.05, xmax = xcomp, ymin = yMIN, ymax = yMAX) +
annotate("rect", fill = "#B3C5DD", alpha = 0.16, xmin = xcomp, xmax = 3.9, ymin = yMIN, ymax = yMAX) +
annotate(geom="text", x=0.16, y=0.038, label="Região", color="#FF85D4") +
annotate(geom="text", x=0.135, y=0.036, label="Saturada", color="#FF85D4") +
annotate(geom="text", x=3.78, y=0.038, label="Região", color="#6B7AFF") +
annotate(geom="text", x=3.81, y=0.036, label="Ativa", color="#6B7AFF") +
geom_line(data = ivCurve, mapping <- aes(x <- x1, y<-y1)) +
scale_colour_manual(TeX('$Corrente\\, I_{B}\\, (?A)$'),
breaks = c("Saída R1","Saída R2","Saída R3","Saída R4","Saída R5","Saída R6","Saída R7","Saída R8","Saída R9","Saída R10", "Saída R11", "Saída R12"),
values = c("#000000","#B1DF1C","#88FB0C","#41F710","#09F668","#03F8C7","#0AB8F8","#900BF6","#CF0FE8","#EE13C6", "purple","red")) +