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")
curve_test
summary(curve_test)
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")
curve_control
summary(curve_control)
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?

Thanks,
DC

Bottom example here for base R graphs: http://www.sthda.com/english/wiki/add-legends-to-plots-in-r-software-the-easiest-way

1 Like

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