我无法看到要显示的图例。
table1b <- table(mydata$SEX, mydata$CLASS)
addmargins(table1b)
colorSex <- c("lightpink", "gray", "lightblue")
barplot(table1b, beside = TRUE,
ylab ="Frequency", ylim = c(0, 150), axes = TRUE,
xlab = "Class", col = colorSex,
main = "Abalones Class by Gender")
legend("topleft", c("Female", "Intersex", "Male"), cex=0.8, fill=colorSex)
它出现以下错误:
Error in strwidth(legend, units = "user", cex = cex, font = text.font) : plot.new has not been called yet