我试图制作一个"堆积的" R中的条形图,以查看一个人的销售组合的构成。数据类似于:
有更多的销售人员(C先生,D先生等)和每次销售的年度预订,这是我的兴趣所在。我有
使用ggplot2显示没有堆叠,只是每个人销售的所有销售的年度预订总额,代码显示:
g <- ggplot(data1, aes(Sales.Person))
g + geom_bar(aes(weight = Annualized.Booking)) +
labs(title = "Sales Person Comparison") +
labs(y = "Annualized Booking total")`
ggplot中是否有办法明显地叠加单个销售额,以便查看总销售组合的构成?或者堆叠条形图不是最佳解决方案?
答案 0 :(得分:0)
你的意思是什么(如@erocoar评论)?
data1 <- data.frame(
Sales.Person = c("A", "A", "C", "B", "B", "A", "C", "C"),
Annualized.Booking = c(115000, 139000, 50100, 120500, 80400, 10400, 50500, 75000)
)
ggplot(data1) +
aes(Sales.Person, Annualized.Booking, fill = factor(Annualized.Booking)) +
geom_col() +
labs(title = "Sales Person Comparison") +
labs(y = "Annualized Booking total") +
guides(fill = FALSE)