Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 如何在ggplot2中增加条形图尺寸?_R_Ggplot2 - Fatal编程技术网

R 如何在ggplot2中增加条形图尺寸?

R 如何在ggplot2中增加条形图尺寸?,r,ggplot2,R,Ggplot2,这就是我得到的数字 正如你所看到的,有些数字是重叠的,有些则是看不见的。我怎样才能增加一点酒吧的宽度,使数字可见?五位数是我的数据中最大的数字。ggplot2允许您像这样调整宽度: ggplot(scount_all, aes(x=classes, y=frequency, group=seasons,fill=seasons)) + scale_fill_manual(name = "Seasons",values=bwPalette(4))+ geom_bar(colour="bla

这就是我得到的数字


正如你所看到的,有些数字是重叠的,有些则是看不见的。我怎样才能增加一点酒吧的宽度,使数字可见?五位数是我的数据中最大的数字。

ggplot2允许您像这样调整宽度:

ggplot(scount_all, aes(x=classes, y=frequency, group=seasons,fill=seasons)) +
  scale_fill_manual(name = "Seasons",values=bwPalette(4))+
  geom_bar(colour="black",stat="identity", position="dodge")+
  geom_text(aes(ymax=frequency,label = paste(sprintf("%s", frequency)),
                hjust= 0.5,vjust=-2,group=seasons),
            size = 2, position = position_dodge(width=.9)) +
  theme_bw()+
  theme(legend.key = element_rect(colour = "black")) +
  guides(fill = guide_legend(override.aes = list(colour = NULL)))

宽度是,我认为,从0到1,其中1意味着这些条占据了100%的可用空间,并且中间没有空间。如果您喜欢它们之间的空白量,但希望它们更宽,则只需将绘图尺寸整体加宽。

为什么不将文本旋转到垂直方向…geom_textangle=90,…?这里给出的答案可能是最后的选择。影响可读性。如果我得不到解决方案,我会让它垂直。@Meso我看到了那个解决方案。不推荐使用Opts。在主题中,binwidth与直方图一起工作。我不知道如何让它直接与geom_bar或theme一起工作你试过阅读吗?参见第二个示例。
 + geom_bar(stat = "identity", width = 1)