[英]Minimize the height of a geom_bar plot
I have a bar plot cutting off the data labels because of height being bigger that other data points. 由于高度比其他数据点大,我有一个条形图切断数据标签。 I want to adjust the height so that the labels are visible. 我想调整高度,以便标签可见。
season batsman total_runs
<int> <chr> <int>
1 2016 V Kohli 973
2 2018 KS Williamson 747
3 2012 CH Gayle 733
4 2013 MEK Hussey 733
5 2019 DA Warner 727
6 2014 RV Uthappa 660
7 2017 DA Warner 641
8 2010 SR Tendulkar 618
9 2008 SE Marsh 616
10 2011 CH Gayle 608
11 2009 ML Hayden 572
12 2015 DA Warner 562
I have tried ylim but does not work in my case. 我试过ylim,但在我的情况下不起作用。
season_top_scorer <- match_full%>%
group_by(season,batsman)%>%
summarize(total_runs = sum(batsman_runs))%>%
arrange(season,desc(total_runs))%>%
filter(total_runs == max(total_runs))%>%
arrange(desc(total_runs))%>%
ggplot(aes(x = season,y = total_runs,fill = batsman))+
geom_bar(stat ="identity")+
ggtitle("Highest run scorer each season")+
theme(axis.text.x = element_text(angle = 90, hjust = 1))+
scale_x_discrete(name="Season",
limits = c(2008,2009,2010,2011,2012,2013,2014,2015,2016,2017,2018,2019))+
geom_text(aes(label= total_runs,vjust= 0 ))+
scale_y_discrete(name = "Total Runs", limits = c(0,250,500,750,1000,1250))
The only problem is with season 2016. The height of bar is too big that its cutting off the label.Any idea what might solve this problem in the above code 唯一的问题是2016年的季节。酒吧的高度太大,以至于它切断了标签。任何想法可以在上面的代码中解决这个问题
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.