Legend in ppp plot
<p>I´m creating a spatial map of trees based on x-y location using the spatstat package and the ppp function. I´ve been able to do this and the size of each point is based on tree diameter. What I haven´t been able to do, and I hope to find some help here, is to create a legend that allows me to show these different circles and also include the 6 tree species within the plot. Here is the code I´m using:</p>

<pre><code>df &lt;- subset(plots, plots$spp == "DF")  # Douglas-fir

dfx &lt;- as.numeric(as.character(df$x))
dfy &lt;- as.numeric(as.character(df$y))
dfd &lt;- as.numeric(as.character(df$d))

dfp &lt;- ppp(dfx, dfy, window = owin(c(0, 100), c(0, 100)),
                  unitname=c("metres","metres"), marks = dfd)
par(mar = c(2, 2, 2, 2))                                           
plot(dfp, main = "", cex = 0.8, markscale = 0.04, 
     bg = rgb(0.1,0.9,0.3,0.5), fg = "black")
</code></pre>

<p>I have a similar structure for every species in the plot (wh for Western Hemlock and the code is the same...)</p>

<p>Thanks!﻿</p>