Ошибка в strwidth (легенда, единицы = "пользователь", cex = cex, font = text.font): plot.new еще не был вызван - PullRequest
0 голосов
/ 31 октября 2018

Я не могу получить легенду для моего барплота.

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
...