I want to make a facet_wrap and at the same time have common legend where it makes sense. By this I mean, that I would like A. gueldenstaedtii to have the same symbols on both graphs. The same goes for A. baerii. Before asking this, I have also tried grid_arrange_shared_legend and plot_grid.
When I run the code below, I get two A. gueldenstaedtii and A. baerii. I would only like 1 A. baerii and 1 A. gueldenstaedtii.
g<-ggplot(data = amp,aes(x = Cycle, y = `Fluorescence (dRn)`, colour=`Species`,group=amp$merge))+
geom_line()+
geom_point()+
theme(text = element_text(size=16), axis.text.x = element_text(size=16),axis.text.y = element_text(size=16) ) +
theme(legend.direction="horizontal",legend.position="top", legend.box = "vertical")+
facet_wrap(~Run, ncol=2, scales = "free")
g
Here are some sample data
,Amplification Plots,Cycle,Fluorescence (dRn),Run,X1,X2,Species,X4,X5,X6,X7,merge
953,"B8, Repl. 5, A. rut,CE.05.10,F05,, FAM",3,0.01839,Second,B8, Repl. 5, A. ruthenus,CE.05.10,F05,, FAM,Second B8
328,"E2, ,A. rut,05.07,F09,R0, FAM",28,0.00713,First,E2, ,A. ruthenus,5.07,F09,R0, FAM,First E2
1059,"D8, Repl. 6, A. bae,CE.05.06,F05,, FAM",9,0.01008,Second,D8, Repl. 6, A. baerii,CE.05.06,F05,, FAM,Second D8
658,"D7, Repl. 2, A. oxy,CE.05.08,F05,, FAM",8,0.00505,Second,D7, Repl. 2, A. oxyrinchus,CE.05.08,F05,, FAM,Second D7
698,"D7, Repl. 2, A. oxy,CE.05.08,F05,, FAM",48,0.00013,Second,D7, Repl. 2, A. oxyrinchus,CE.05.08,F05,, FAM,Second D7
866,"H7, Repl. 4, A. gue,CE.05.11,F05,, FAM",16,-0.00405,Second,H7, Repl. 4, A. gueldenstaedtii,CE.05.11,F05,, FAM,Second H7
1284,"F1, Repl. 14, 10^4_ste,CE.05.06,F0, FAM",34,1.48204,Second,F1, Repl. 14, 10^4 A. stellatus,CE.05.06,F0, FAM,F1,Second F1
441,"G2, ,A. bae,05.02,F09,R0, FAM",41,-0.00338,First,G2, ,A. baerii,5.02,F09,R0, FAM,First G2
1262,"F1, Repl. 14, 10^4_ste,CE.05.06,F0, FAM",12,8.00E-04,Second,F1, Repl. 14, 10^4 A. stellatus,CE.05.06,F0, FAM,F1,Second F1
1196,"B1, Repl. 13, 10^5_ste,CE.05.06,F0, FAM",46,2.41789,Second,B1, Repl. 13, 10^5 A. stellatus,CE.05.06,F0, FAM,B1,Second B1
1470,"F2, Repl. 16, 10^2_ste,CE.05.06,F0, FAM",20,-0.007,Second,F2, Repl. 16, 10^2 A. stellatus,CE.05.06,F0, FAM,F2,Second F2
831,"G7, Repl. 4, A. gue,CE.05.11,F05,, FAM",31,-0.00175,Second,G7, Repl. 4, A. gueldenstaedtii,CE.05.11,F05,, FAM,Second G7
506,"A7, Repl. 1, H. hus,CE.05.04,F05,, FAM",6,0.00787,Second,A7, Repl. 1, H. huso,CE.05.04,F05,, FAM,Second A7
341,"E2, ,A. rut,05.07,F09,R0, FAM",41,-0.00624,First,E2, ,A. ruthenus,5.07,F09,R0, FAM,First E2
310,"E2, ,A. rut,05.07,F09,R0, FAM",10,-0.00336,First,E2, ,A. ruthenus,5.07,F09,R0, FAM,First E2
865,"H7, Repl. 4, A. gue,CE.05.11,F05,, FAM",15,-0.00172,Second,H7, Repl. 4, A. gueldenstaedtii,CE.05.11,F05,, FAM,Second H7
465,"H2, ,A. bae,05.02,F09,R0, FAM",15,-0.00135,First,H2, ,A. baerii,5.02,F09,R0, FAM,First H2
1442,"E2, Repl. 16, 10^2_ste,CE.05.06,F0, FAM",42,0.00813,Second,E2, Repl. 16, 10^2 A. stellatus,CE.05.06,F0, FAM,E2,Second E2
849,"G7, Repl. 4, A. gue,CE.05.11,F05,, FAM",49,2.79364,Second,G7, Repl. 4, A. gueldenstaedtii,CE.05.11,F05,, FAM,Second G7
370,"F2, ,A. rut,05.07,F09,R0, FAM",20,-0.00215,First,F2, ,A. ruthenus,5.07,F09,R0, FAM,First F2
46,"A2, ,A. gue,05.11,F09,R0, FAM",46,0.00282,First,A2, ,A. gueldenstaedtii,5.11,F09,R0, FAM,First A2
1401,"E2, Repl. 16, 10^2_ste,CE.05.06,F0, FAM",1,0.00329,Second,E2, Repl. 16, 10^2 A. stellatus,CE.05.06,F0, FAM,E2,Second E2
970,"B8, Repl. 5, A. rut,CE.05.10,F05,, FAM",20,-0.01552,Second,B8, Repl. 5, A. ruthenus,CE.05.10,F05,, FAM,Second B8
1371,"B2, Repl. 15, 10^3_ste,CE.05.06,F0, FAM",21,0.01097,Second,B2, Repl. 15, 10^3 A. stellatus,CE.05.06,F0, FAM,B2,Second B2
1318,"A2, Repl. 15, 10^3_ste,CE.05.06,F0, FAM",18,-0.01207,Second,A2, Repl. 15, 10^3 A. stellatus,CE.05.06,F0, FAM,A2,Second A2
112,"B2, ,A. gue,05.11,F09,R0, FAM",12,0.00227,First,B2, ,A. gueldenstaedtii,5.11,F09,R0, FAM,First B2
1177,"B1, Repl. 13, 10^5_ste,CE.05.06,F0, FAM",27,0.59044,Second,B1, Repl. 13, 10^5 A. stellatus,CE.05.06,F0, FAM,B1,Second B1
907,"A8, Repl. 5, A. rut,CE.05.10,F05,, FAM",7,-0.01188,Second,A8, Repl. 5, A. ruthenus,CE.05.10,F05,, FAM,Second A8
1049,"C8, Repl. 6, A. bae,CE.05.06,F05,, FAM",49,0.00874,Second,C8, Repl. 6, A. baerii,CE.05.06,F05,, FAM,Second C8
253,"D2, ,A. rut,05.10,F09,R0, FAM",3,0.00268,First,D2, ,A. ruthenus,5.1,F09,R0, FAM,First D2