我为qPCR生物学数据制作了一个ggplot,很难将图例添加到geom_smooth图上。我想将图例添加到图形本身的图像上。我尝试了一堆scale_color_
函数都无济于事。如果有人有任何提示,请告诉我您的建议。
尝试过scale_color_continuous
和scale_color_discrete
ggplot(plasmid_EphA2_8_2_19, aes(x = Sample, y = Cq)) + geom_boxplot()+ theme_classic()
primer_1 <- plasmid_EphA2_8_2_19 %>% filter(Sample == "Primer 1")
primer_2 <- plasmid_EphA2_8_2_19 %>% filter(Sample == "Primer 2")
primer_3 <- plasmid_EphA2_8_2_19 %>% filter(Sample == "Primer 3")
primer_4 <- plasmid_EphA2_8_2_19 %>% filter(Sample == "Primer 4")
primer_results <- ggplot() + geom_smooth(data = primer_1, mapping = aes(x = `Concentration (ng/mL)`, y = Cq), level = 0.05 , color='red') + geom_smooth(data = primer_2, mapping = aes(x = `Concentration (ng/mL)`, y = Cq), level = 0.05 , color ='blue') + geom_smooth(data = primer_3, mapping = aes(x = `Concentration (ng/mL)`, y = Cq), level = 0.05 , color ='darkgreen') + geom_smooth(data = primer_4, mapping = aes(x = `Concentration (ng/mL)`, y = Cq), level = 0.05 , color ='purple') + theme_classic()
规模:
深红色-底漆1 蓝色-底漆2 深绿色-底漆3 紫色-底漆4
答案 0 :(得分:0)
我不太明白为什么要分割数据,但原则上会这样做
plasmid_EphA2_8_2_19 %>%
ggplot(aes(x= `Concentration (ng/mL)`, y = Cq, color = Sample))+
geom_smooth()
应创建所需的输出