The set up is this: There are 10 trees within a 20 by 20 m quadrat in a forest. For each tree we know the species, the diameter (in cm), and the location within the quadrat using x,y coordinates.
I would like to plot the trees within the quadrat, where the size of the points are to scale, and each species is represented by a different colour circle.
Use this data for an example:
tag <- as.character(c(1,2,3,4,5,6,7,8,9,10))
species <- c("A","A","A","A","B","B","B","C","C","D")
diameter <- c(50,20,55,30,30,45,15,20,35,45)
x <- c(9,4,5,14,8,19,9,12,10,2)
y <- c(6,7,15,16,12,4,19,2,14,9)
df <- data.frame(tag, species, diameter, x, y)
First I create the point pattern
species_map <- ppp(df$x, df$y, c(0,20), c(0,20))
Then I mark the species and diameter
marks(species_map) <- data.frame(m1 = df$species, m2=(df$diameter))
Now I can plot the point pattern and each point is to scale thanks to the marks on the diameter. The "markscale" bit is set to 0.01 because the diamter measurements are in cm and the quadrat size is defined in meters.
plot(species_map, which.marks=2, markscale=.01)
Now I want to make the circles of different species different colours, but this is where I'm stuck.
If I try to make a plot that includes both of my marks I just get 2 separate plots, with one using different size points to represent diameter (correctly) and one using different characters to represent different species.
plot(species_map, which.marks= c(1,2), markscale=.01)
How can I get this plot to represent different species using different colors of the same character while ALSO plotting the points to scale?
And how can I make it produce 1 single plot?
Thank you in advance.
Jay