【发布时间】:2019-03-28 11:40:51
【问题描述】:
我有一个长数据框格式,它是这样创建的:
testAppVectorJG <- c(17, 155, 200, 200, 382, 499, 548, 548, 642, 642, 699, 699)
testVectorJG <- c(testAppVectorJG[1], diff(testAppVectorJG))
testAppVectorJW <- c(145, 209, 366, 548, 548, 613, 746, 928, 1064, 1266, 1371, 1573)
testVectorJW <- c(testAppVectorJW[1], diff(testAppVectorJW))
test_df <- data.frame(puntenvector = c(testVectorJG, testVectorJW),
team = c(rep("Jasper & Gijs", length(testAppVectorJG)),
rep("Jaap & Wil", length(testAppVectorJW))),
Rondenummer = as.factor(1:length(testVectorJG)))
我想制作一个堆叠条形图,每个“Rondenummer”(即已玩的回合数)都有一个条形图。我想查看每支球队每轮得分的百分比/分布。
到目前为止我已经尝试过:
ggplot(data = test_df, aes(Rondenummer)) +
geom_bar(aes(x = puntenvector, fill = team))
然后我得到:
Warning message:
position_stack requires non-overlapping x intervals
根本不是我想要的情节。我如何实现这个相当简单的情节?
【问题讨论】:
标签: r ggplot2 bar-chart geom-bar stacked-chart