如何在此maptree代码中添加图例?

时间:2018-01-27 23:21:01

标签: r

我的代码是:

maptree.r = function(dat, spname = "HL") {
  x = dat$x
  y = dat$y
  z = dat$z
  sp = dat$sp
  xy.interp = interp(x,y,z)

  image2D(main = "Different Sizes of Western Hemlock Trees",
          xlab = "?", 
          ylab = "?",
          xy.interp,
          col = topo.colors(12),
          sp = T)

  contour2D(xy.interp$z, 
            x = xy.interp$x, 
            y = xy.interp$y, 
            nlevels = 15, 
            col = "black", 
            add = T)

  points(x[sp == "HL" & dbh < 10], 
         y[sp == "HL" & dbh < 10], 
         xlab = "x", 
         ylab = "y", 
         col = "blue")

  points(x[sp == "HL" & dbh >= 10 & dbh < 25],
         y[sp == "HL" & dbh >= 10 & dbh < 25], 
         col = "blue", 
         cex = 2)

  points(x[sp == "HL" & dbh > 25], 
         y[sp == "HL" & dbh >= 25], 
         col = "blue", 
         cex = 3)
}

maptree.r(victoria.dat, "HL")

(抱歉第一次发帖,不知道为什么代码不会在这里正确粘贴)

and the plot looks like (image at this link)

我需要添加一个图例,我假设的是不同大小的点和它们代表什么,但我是新编码,不知道如何去做这个或代码中的传奇应该在哪里放置。 谢谢你的帮助

0 个答案:

没有答案