How can I add a legend to a boxplot

HI there!!!
I have generated the following curve by using the following codes (using vegan package). I want to add a legend for the two curves. Pink as "control" and green as "test". How can I do this?
My code:

curve_test <- specaccum(test, method = "random")
plot(curve_test, ci.type="bar", col="blue", lwd=2, ci.lty=0, xlab = "Sample size", ylab = "Species number")
boxplot(curve_test, col="hotpink", add=TRUE, pch="+")

curve_control <- specaccum(control, method = "random")
plot(curve_control, add = TRUE,  ci.type="bar", col="red", lwd=2, ci.lty=0)
boxplot(curve_control, col="lightgreen", add=TRUE, pch="+") 

title(main = "Species accumulation curve of rarefied data")

This is the curve generated:

Can anyone please help me?


Bottom example here for base R graphs:

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.