R:缩放、图例和带有条形图的轴

R:缩放、图例和带有条形图的轴,r,plot,R,Plot,我在图例、缩放文本和命名单个轴方面遇到问题 代码: youtube\u 1我很难看清你的问题是什么,因为“空间”不是一个定义明确的对象 “宽度错误/2:二进制运算符的非数字参数另外:警告消息:平均值。默认值(宽度):参数不是数字或逻辑参数:返回NA”是由于不正确指定图例造成的。您需要在barplot()中使用args.legend 或者,另一种解决方案是在事件发生后指定图例: barplot( groups , main="Rating" , ylab="Number of vote

我在图例、缩放文本和命名单个轴方面遇到问题

代码:


youtube\u 1我很难看清你的问题是什么,因为“空间”不是一个定义明确的对象

“宽度错误/2:二进制运算符的非数字参数另外:警告消息:平均值。默认值(宽度):参数不是数字或逻辑参数:返回NA”是由于不正确指定图例造成的。您需要在barplot()中使用args.legend

或者,另一种解决方案是在事件发生后指定图例:

barplot(
 groups , 
  main="Rating" ,
  ylab="Number of votes over time (people under 50 vs, people over 50)" ,
  xlab="Year 1 , Year 2 , Year 3 " ,
  col=c("yellow" , "green" ) ,
  beside=TRUE ,
  ylim= range(0 , 10) ,
)

legend("topright" , legend=c("Young" , "Old") , col=c("yellow" , "green")) 
可以使用barchart()中的名称为每个条形指定标签,也可以使用cex指定名称的大小。名称:

barplot(
  groups , 
  main="Rating" ,
  ylab="Number of votes over time (people under 50 vs, people over 50)" ,
  names=row.names(groups),
  cex.names=0.75
  col=c("yellow" , "green" ) ,
  beside=TRUE ,
  ylim= range(0 , 10) ,
)
barplot(
 groups , 
  main="Rating" ,
  ylab="Number of votes over time (people under 50 vs, people over 50)" ,
  xlab="Year 1 , Year 2 , Year 3 " ,
  col=c("yellow" , "green" ) ,
  beside=TRUE ,
  ylim= range(0 , 10) ,
)

legend("topright" , legend=c("Young" , "Old") , col=c("yellow" , "green")) 
barplot(
  groups , 
  main="Rating" ,
  ylab="Number of votes over time (people under 50 vs, people over 50)" ,
  names=row.names(groups),
  cex.names=0.75
  col=c("yellow" , "green" ) ,
  beside=TRUE ,
  ylim= range(0 , 10) ,
)