strwidth错误(传奇,单位=“用户”,cex = cex,字体= text.font):plot.new尚未被调用

时间:2018-10-31 16:54:15

标签: r bar-chart legend

我无法看到要显示的图例。

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

0 个答案:

没有答案