R:plot 和结果是"plot.new has not been called yet"



数据(删节版):

m1 1
m2 2
m3 3
m4 0
m5 32
m6 12
m7 42
m8 56
m9 29

注意:0应该表示我的图

中的一个空格代码:

barplot(
  name,
  main="Mike vs. Ike" , 
  ylab="Number of criminal offences of two different people" , 
  xlab="" , 
  col=c("yellow" , "blue" ) , 
  beside=TRUE , 
  ylim= range(0 , 10) ,  
  las=2 , 
  axes=TRUE ,

   names.arg = c("Mike: number of offences in: 1 day"      , 
                    "Ike: number of offences in: 1 day"     ,
                    ""                       , 
                    "Mike: number of offences in: 1 week"      ,
                    "Ike: number of offences in: 1 week"     , 
                        ""                       ,
                        "Mike: number of offences in: 1 month"        ,
                        "Ike: number of offences in: 1 month"       , 
                        ""                       ,
                        "Mike: number of offences in: 1 year"     ,
                        "Mike: number of offences in: 1 year"   

           ) ,
             legend(
  "topright" , 
  c("Mike" , "Ike") , 
  col=c("yellow" , "green") , 
  pch=c(22:22) ,
  cex=0.75 )
)  

错误:

Error in strwidth(legend, units = "user", cex = cex, font = text.font) : 
  plot.new has not been called yet

十亿美元问题:

我如何缩放names.arglegend来适合我的图

提前退房

不要在这里读pass (stack表示代码太多)。

苹果桔子桔子桔子桔子桔子桔子桔子桔子桔子桔子桔子桔子桔子桔子桔子桔子桔子桔子桔子桔子桔子桔子桔子桔子桔子桔子桔子桔子桔子桔子桔子

我认为你的问题是,你调用legend() 内部你调用boxplot(),而它应该被称为。至少这是导致误差的原因。然而,我不确定你所说的"缩放"图例或名称到底是什么意思。

最新更新