您可能想尝试真正的 R 绘图,其功能IMO可能不那么令人困惑且更容易学习,而且定制起来肯定要好得多。
有两个步骤,定义标签和颜色,然后是带有图例的绘图。
# define labels and colors beforehand
mutants <- sort(unique(edtct3$Mutant)) # unique and alph. sorted mutants
clr <- hcl.colors(8, "Spectral")
op <- par(mar=c(5, 5, 4, 7.5)) # modify margins of plot region (B, L, T, R)
# plot
with(edtct3, plot(x=Time, y=Mean, type="n", ## empty plot: type="n"
main="Effective PSII Quantum Yield across SP1 Mutants",
ylab="Effective PSII Quantum Yield",
xlab="Actinic PPFD"))
# lines and points: loop over the mutants with an `sapply`
# the actual function is `lines()`
sapply(seq(mutants), function(x) ## `seq(mutants)` makes a loop sequence over the mutants
with(edtct3[edtct3$Mutant == mutants[x], ], ## subsetting
lines(x=Time, y=Mean, type="o", pch=16, col=clr[x]))) ## type="o" makes lines and points
# legend
legend(x=20.5, y=1.69, xpd=TRUE, legend=labs, pch=15, col=clr, cex=.9,
text.font=c(1, rep(3, 7))) ## recall the "face" vector from former question
par(op) # reset margins of plot region
产量
数据:
edtc3 <- structure(list(Time = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 6, 6,
6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
6, 6, 6, 6, 6, 6, 6, 6, 6, 11, 11, 11, 11, 11, 11, 11, 11, 11,
11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
11, 11, 11, 11, 11, 11, 11, 19, 19, 19, 19, 19, 19, 19, 19, 19,
19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
19, 19, 19, 19, 19, 19, 19), Mutant = c("sp2-3 ppi1", "ppi1",
"WT", "sp2-6 ppi1", "sp2-4", "WT", "sp2-3 ppi1", "sp2-8 ppi1",
"sp2 ppi1", "ppi1", "sp2-6 ppi1", "sp2-8 ppi1", "sp2 ppi1", "sp2-6 ppi1",
"sp2-5 ppi1", "WT", "sp2-4", "sp2 ppi1", "sp2-4", "sp2-5 ppi1",
"sp2-5 ppi1", "sp2-4", "sp2 ppi1", "WT", "sp2-6 ppi1", "sp2-8 ppi1",
"sp2-3 ppi1", "sp2-8 ppi1", "ppi1", "ppi1", "sp2-3 ppi1", "sp2-5 ppi1",
"sp2-5 ppi1", "sp2-6 ppi1", "ppi1", "WT", "sp2-8 ppi1", "sp2-8 ppi1",
"sp2-3 ppi1", "sp2 ppi1", "ppi1", "sp2-6 ppi1", "WT", "sp2-8 ppi1",
"WT", "sp2-3 ppi1", "sp2-5 ppi1", "ppi1", "sp2-3 ppi1", "sp2-6 ppi1",
"sp2-5 ppi1", "sp2-3 ppi1", "sp2 ppi1", "sp2-5 ppi1", "sp2 ppi1",
"ppi1", "sp2-4", "sp2-4", "sp2-4", "sp2-4", "WT", "sp2 ppi1",
"sp2-6 ppi1", "sp2-8 ppi1", "sp2 ppi1", "sp2-4", "sp2-4", "sp2-8 ppi1",
"sp2-4", "sp2-3 ppi1", "sp2-8 ppi1", "sp2-4", "WT", "sp2 ppi1",
"ppi1", "sp2 ppi1", "sp2-5 ppi1", "WT", "sp2-3 ppi1", "sp2-3 ppi1",
"sp2-3 ppi1", "sp2-6 ppi1", "sp2-5 ppi1", "ppi1", "ppi1", "sp2-8 ppi1",
"sp2 ppi1", "WT", "WT", "sp2-6 ppi1", "sp2-5 ppi1", "ppi1", "sp2-5 ppi1",
"sp2-6 ppi1", "sp2-6 ppi1", "sp2-8 ppi1", "sp2-3 ppi1", "sp2 ppi1",
"sp2-5 ppi1", "sp2-6 ppi1", "sp2-3 ppi1", "sp2-4", "sp2-4", "sp2-6 ppi1",
"sp2-5 ppi1", "sp2-4", "sp2-8 ppi1", "ppi1", "ppi1", "WT", "sp2 ppi1",
"sp2 ppi1", "ppi1", "sp2-6 ppi1", "ppi1", "sp2-4", "sp2-5 ppi1",
"sp2-3 ppi1", "sp2-6 ppi1", "sp2-5 ppi1", "sp2-8 ppi1", "WT",
"sp2 ppi1", "sp2-8 ppi1", "sp2-3 ppi1", "sp2-8 ppi1", "WT", "WT"
), Mean = c(0.91, 0.59, 1.14, 0.74, 1.08, 1.65, 0.77, 1.34, 0.65,
0.61, 0.86, 1.3, 0.82, 0.84, 0.97, 1.29, 1.15, 0.84, 1, 1.04,
0.78, 1.01, 1.02, 1.33, 0.88, 1.25, 0.78, 1.25, 0.8, 0.67, 0.85,
0.9, 1.04, 0.84, 0.67, 1.65, 1.25, 1.34, 0.77, 1.02, 0.59, 0.88,
1.33, 1.3, 1.29, 0.91, 0.78, 0.8, 0.78, 0.86, 0.9, 0.85, 0.84,
0.97, 0.65, 0.61, 1.01, 1.08, 1.15, 1, 1.14, 0.82, 0.74, 1.25,
1.02, 1.08, 1.15, 1.25, 1.01, 0.85, 1.25, 1, 1.29, 0.84, 0.59,
0.82, 1.04, 1.33, 0.77, 0.91, 0.78, 0.86, 0.78, 0.67, 0.61, 1.34,
0.65, 1.65, 1.14, 0.84, 0.9, 0.8, 0.97, 0.74, 0.88, 1.3, 0.78,
0.84, 1.04, 0.88, 0.91, 1.01, 1.15, 0.74, 0.78, 1, 1.3, 0.67,
0.8, 1.14, 1.02, 0.82, 0.59, 0.84, 0.61, 1.08, 0.9, 0.77, 0.86,
0.97, 1.34, 1.29, 0.65, 1.25, 0.85, 1.25, 1.65, 1.33)), row.names = c("17",
"5", "1", "25", "10", "4", "18", "32", "15", "7", "27", "31",
"14", "26", "24", "3", "9", "16", "11", "22", "21", "12", "13",
"2", "28", "29", "19", "30", "6", "8", "20", "23", "221", "261",
"81", "41", "291", "321", "181", "131", "51", "281", "210", "311",
"33", "171", "211", "61", "191", "271", "231", "201", "161",
"241", "151", "71", "121", "101", "91", "111", "110", "141",
"251", "301", "132", "102", "92", "292", "122", "202", "302",
"112", "34", "162", "52", "142", "222", "212", "182", "172",
"192", "272", "213", "82", "72", "322", "152", "42", "113", "262",
"232", "62", "242", "252", "282", "312", "193", "163", "223",
"283", "173", "123", "93", "253", "214", "114", "313", "83",
"63", "115", "133", "143", "53", "263", "73", "103", "233", "183",
"273", "243", "323", "35", "153", "303", "203", "293", "43",
"215"), class = "data.frame")