0
I am trying to add a caption identifying that the "ball" is the mean and the "line" is the median of the boxplot chart as follows:
mediasCon1 = tapply(dados$FS, dados$Trat, mean)
boxplot(dados$FS ~ dados$Trat, data = dados, col="gray",
xlab = 'Tratamentos', ylab = 'Espermatozoides - Cauda Solta')
points(1:3, mediasCon1, col = 'black', pch = 16)
legend("topleft", legend=c("Média", "Mediana"),
lty=c(NA,1), col="black", lwd=1:3, bty="n", pch=c(16,NA))
However, when using the ggplot2 function, the following error appears:
ggplot(data=dados, aes(x=Trat, y=FS)) + geom_boxplot(fill=c("#DEEBF7","#2171B5","#034E7B"),color="black") +
xlab('Tratamentos') +
ylab('Espermatozoides - Cauda Solta') +
stat_summary(fun=mean, colour="black", geom="point",
shape=18, size=5) +
theme(axis.title = element_text(size = 20),
axis.text = element_text(size = 16)) +
legend("topleft", legend=c("Média", "Mediana"),
lty=c(NA,1), col="black", lwd=1:3, bty="n", pch=c(16,NA))
Error in strwidth(legend, units = "user", cex = cex, font = text.font) :
plot.new has not been called yet
Thanks Carlos!!!!!!
– user55546