R Y轴赢得';t在ggplot中从0开始
在这个图中,我将ylim排序为0,但是y轴似乎从-1开始,这很烦人。我真的很喜欢y轴统计为0。解决方案R Y轴赢得';t在ggplot中从0开始,r,ggplot2,R,Ggplot2,在这个图中,我将ylim排序为0,但是y轴似乎从-1开始,这很烦人。我真的很喜欢y轴统计为0。解决方案 sub1=subset(table.popstat,POPSTAT==1,select=c(1,3)) ggplot(sub1, aes(x=YR,y=Freq)) + ylim(0,15) + geom_bar(stat='identity') + annotate("text",x=3,y=14.9,label="Population status",cex=10) 另外,我有
sub1=subset(table.popstat,POPSTAT==1,select=c(1,3))
ggplot(sub1, aes(x=YR,y=Freq)) + ylim(0,15) +
geom_bar(stat='identity') +
annotate("text",x=3,y=14.9,label="Population status",cex=10)
另外,我有30个这样的图,y轴上有许多不同的范围。我需要一个通用代码,将文本放置在图形的左上角,而不管ymax是什么。可行吗?ggplot会自动略微延伸轴,以确保有空间放置点进行打印。可以使用expand参数关闭此行为
ggplot(sub1, aes(x=YR,y=Freq)) +
geom_bar(stat='identity') +
annotate("text",x=3,y=14.9,label="Population status",cex=10) +
scale_y_continuous(expand = c(0, 0), limits = c(0, 15))
这个函数(扩展(mult=c(0,0.05))可能有帮助我们不知道数据是什么样子。如果缺少括号,则输出全部或部分的
摘要(table.popstat)
或dput()
。
p + scale_y_continuous(
limits = c(0,max_num),
expand = expansion(mult = c(0,0.05))
)