- 此问题在此处已有答案**:
How to display all x labels in R barplot?(4个答案)
9小时前关门了。
我想在条形图中按组排序绘制测试结果。我想插入所有可能的结果(0到50点),即使没有人达到那个结果。
我得到了这个,但我想要真正长度的空格。例如,在30到41之间。
team=c("m","w","m","w","w","m","m","w","m","w","m","w","m","m","m","m","m","w","w","m")
pts=c(12,27,6,26,29,16,23,30,20,17,41,14,8,9,5,7,28,42,6,27)`
df <- data.frame(team,pts)
df
barplot(table(df$team, df$pts), las=1, beside=TRUE,border="white",
axis.lty = 1, xlim=c(0,50), ylim= c(0,2),axes=FALSE,
col=c("lightblue","pink")
)
现在我想知道,如何自定义x轴,以便显示所有可能的结果?
1条答案
按热度按时间wydwbb8l1#
ggplot解决方案如下所示:
1.加载包,创建数据框
2.用x轴的整个范围(从0到50)绘制条形图
3.结果
希望这是有帮助的。