【问题标题】:R: plot & the result is "plot.new has not been called yet"R: plot & 结果是“plot.new 还没有被调用”
【发布时间】:2014-05-07 02:21:31
【问题描述】:

数据(精简版):

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(堆栈说太多代码)。

苹果橙苹果橙苹果橙苹果橙苹果橙苹果橙苹果橙苹果橙苹果橙苹果橙苹果橙苹果橙苹果橙苹果橙苹果橙

【问题讨论】:

    标签: r graph plot syntax-error


    【解决方案1】:

    我认为你的问题是你在调用legend() inside 你对boxplot() 的调用,而它应该在之后调用。至少这就是给你错误的原因。但是,我不确定您所说的“缩放”图例或名称​​到底是什么意思。

    【讨论】:

    • @user3609325 好吧,由于您的示例数据似乎不足以实际运行代码,所以我不确定您在看什么。您可以尝试将其放置在绘图空间中的其他位置,或者您可以通过使用 par(mar=) 增加边距并使用 par(xpd=NA) 将其移到绘图之外,从而将其移到边缘。
    • @user3609325 这有点含糊。你到底尝试了什么?您是否阅读了?par 的文档?你在boxplot()之前打电话了吗?
    • 我在箱线图之前调用了 par(mar)。以后我应该叫它吗?
    • @user3609325 没有。之前。但是你到底传递了什么值?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-09-06
    • 1970-01-01
    • 2017-04-17
    • 1970-01-01
    相关资源
    最近更新 更多