Plot the quantity/quality pollination landscapes for tomato bee visitors in R. Inspired in Pedro Jordano's lab work (Schupp EW, Jordano P, Gómez JM (2010) New Phytol 188:333–353) https://github.com/pedroj/effectiveness
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(plotrix) | |
#manually enter data | |
d <- data.frame( | |
Bee_group = c("Bombus", "Dark", "Green", "Lasioglossum"), | |
Efficiency = c(106.86207, 81.50000, 80.66667, 59.27586), | |
Eff_SE = c(15.56551, 20.12130, 17.97529, 12.25689), | |
Visitation = c(2.8333333, 0.2222222, 2.2222222, 5.6666667), | |
Visit_SE = c(0.8333333, 0.1008317, 0.7119684, 1.0966378) | |
) | |
#create a grid with value x (visitation), y (efficiency) and z = x*y. | |
grid = expand.grid(list(x=seq(0, 8, 0.1), y=seq(0, 175, 1))) | |
grid$z = grid$x * grid$y | |
#use loess to have z in a matrix format. | |
total.loess = loess(data=grid, z ~ x * y, degree=2, span=0.01) | |
z = predict(total.loess, newdata = grid) | |
#Plot the surface | |
image(seq(0, 8, 0.1), seq(0, 175, 1), z, | |
xlab = "", ylab = "", | |
main = "Tomato pollination landscape", col = sort(heat.colors(10, 0.5), decreasing= TRUE), las = 1) | |
box() | |
#Plot the position of the different groups on top | |
par(new = TRUE) | |
x = c(0,8) | |
y = c(0,175) | |
plot(x,y, type = "n",axes= FALSE, ylab = "Quality", xlab = "Quantity", | |
las = 1, xlim = c(0.1,7.9), ylim = c(0.1,174)) | |
for(i in 1:4){ | |
arrows(d[i,4]-d[i,5],d[i,2],d[i,4]+d[i,5],d[i,2], | |
length=.05,angle=90,code=3, col = i) | |
arrows(d[i,4],d[i,2]+d[i,3],d[i,4],d[i,2]-d[i,3], | |
length=.05,angle=90,code=3, col = i) | |
#alternative with elipses | |
#draw.ellipse(d[i,4],d[i,2], a = d[i,5], b = d[i,3], border = i, | |
# col = NULL, lty = 1, lwd = 1) | |
} | |
legend(x= 5 ,y= 175 ,legend= d[,1], lty= 1, col= c(1:4), cex = 0.7) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment