我有一个像这样的data.frame。我想在堆叠的条形图中以y轴显示总捕获值,以中心显示百分比。我该怎么办?请帮忙。 (注意:下图的y轴中的值不正确,我只是通过涂漆完成)
现在我正在运行这段代码。
data %>% mutate(totalcatch = totalcatch / sum(totalcatch),
clust4 = paste0("Cluster-", clust4)) %>%
ggplot(aes(x = "", y = totalcatch, fill = clust4)) +
geom_bar(stat = "identity", color = "black", width = .4)+
labs(fill = "cluster")+xlab("cluster")+
scale_fill_manual(labels=c("1", "2","3","4"),
values = c("yellow","red","green","blue"))
clust4 totalcatch
1 227746.8
2 78691.7
3 252128.8
4 61963.6