我的代码在这里
Yr = c("2016","2017","2016","2017","2016","2017")
Type = c("A","A","B","B","C","C")
Value = c(73,183,160,476,11,73)
Percentage = c(29.92,25.00,65.57,65.03,4.51,9.97)
p1Data <- data.frame(Yr,Type,Value,Percentage)
library(ggplot2)
p1 <- ggplot(p1Data, aes(Type, Value, fill = Yr)) +
geom_bar(stat = "identity", position = position_dodge(width = 0.9)) +
theme(axis.title.x = element_blank(), plot.title = element_text(hjust = 0)) +
geom_text(aes(label = paste(Value, paste(Percentage, "%"), sep = "\n"), y = Value), size = 4, vjust = 1.5, position = position_dodge(width = 0.9)) +
ggtitle("2016 V.S. 2017") +
labs(fill = "Catagory")