我将条形图分组为年份,并将其作为x轴上的分组因子。我只有2012年和2018年的数据。 x轴上有2013年至2017年的空间,我要删除此空间。
plot2012and2018 <- ggplot(GYB, aes(x = Year,)) +
geom_bar(aes(color = Cast, fill = Cast),
stat = "count", position = position_dodge(0.8),
width = 0.7) +
scale_color_manual(values = c("#0073C2FF", "#EFC000FF"))+
scale_fill_manual(values = c("#0073C2FF", "#EFC000FF"))+
labs(y= "Count", x= "Year", title="GYB 2012 and 2018")
plot2012and2018