legend(x, y = NULL, legend, fill = NULL, col = par("col"), border = "black", lty, lwd, pch, angle = 45, density = NULL, bty = "o", bg = par("bg"), box.lwd = par("lwd"), box.lty = par("lty"), box.col = par("fg"), pt.bg = NA, cex = 1, pt.cex = cex, pt.lwd = lwd, xjust = 0, yjust = 1, x.intersp = 1, y.intersp = 1, adj = c(0, 0.5), text.width = NULL, text.col = par("col"), text.font = NULL, merge = do.lines && has.pch, trace = FALSE, plot = TRUE, ncol = 1, horiz = FALSE, title = NULL, inset = 0, xpd, title.col = text.col, title.adj = 0.5, seg.len = 2)x, yX,y用于定位图例,也可用单键词"bottomright", "bottom", "bottomleft", "left", "topleft", "top", "topright", "right" and "center"legend字符或表达式向量fill用特定的颜色进行填充col图例中出现的点或线的颜色border当fill = 参数存在的情况下,填充色的边框lty, lwd图例中线的类型与宽度pch点的类型angle阴影的角度density阴影线的密度bty图例框是否画出,o为画出,默认为n不画出bgbty != "n"时,图例的背景色box.lty, box.lwd, box.colbty = "o"时,图例框的类型,box.lty决定是否为虚线,box.lwd决定粗线,box.col决定颜色pt.bg点的背景色cex字符大小pt.cex点的大小pt.lwd点的边缘的线宽x.intersp图例中文字离图片的水平距离y.intersp图例中文字离图片的垂直距离adj图例中字体的相对位置text.width图例字体所占的宽度text.col图例字体的颜色text.font图例字体mergelogical, if TRUE,合并点与线,但不填充图例框,默认为TRUEtracelogical; if TRUE显示图例信息.plotlogical. If FALSE不画出图例ncol图例中分类的列数horizlogical; if TRUE,水平放置图例title给图例加标题inset当图例用关键词设置位置后,inset = 分数,可以设置其相对位置xpdxpd=FALSE,即不允许在作图区域外作图,改为TRUE即可,与par()参数配合使用。title.col标题颜色title.adj图例标题的相对位置,0.5为默认,在中间。0最左,1为最右。seg.lenlty 与lwd的线长,长度单位为字符宽度