【发布时间】:2018-02-09 20:38:05
【问题描述】:
我创建了一个条形图来显示越南的人口分布。这是我的vietnam2015 数据:
Year Age.group Est.pop
1 2015 0-4 7753
2 2015 5-9 7233
3 2015 10-14 6623
4 2015 15-19 6982
5 2015 20-24 8817
6 2015 25-29 8674
7 2015 30-34 7947
8 2015 35-39 7166
9 2015 40-44 6653
10 2015 45-49 6011
11 2015 50-54 5469
12 2015 55-59 4623
13 2015 60-64 3310
14 2015 65-69 1896
15 2015 70-74 1375
16 2015 75-79 1162
17 2015 80+ 1878
这是我的条形图,我想知道我是否也可以制作点图而不是条形图。
Library(tidyverse)
vietnam2015 %>%
filter(Age.group != "5-9") %>% # Somehow this weird value creeped into the data frame, is therefor filtered out.
ggplot(aes(x = Age.group, y = Est.pop)) +
geom_col(colour = "black",
fill = "#FFEB3B")
现在我知道点图通常用于数据点不多的数据。但是我可以创建一个点图,其中一个点代表 1000 人或 100 万人吗?我喜欢更好地沟通酒吧由人组成。比如flowingdata的例子和中间图片:
【问题讨论】:
-
你看过
geom_dotplot()吗? -
是的,但我似乎找不到合适的 binwidth 数。我收到一个错误:
stat_bindot() using bins = 30. Pick better value with binwidth.还有geom_dotplot文档说...and dots are stacked, with each dot representing one observation。
标签: r plot ggplot2 histogram bar-chart