我的数据是
PC_Name Electors_2009 Electors_2014 Electors_2019 Voters_2009 Voters_2014
1 Amritsar 1241099 1477262 1507875 814503 1007196
2 Anandpur Sahib 1338596 1564721 1698876 904606 1086563
3 Bhatinda 1336790 1525289 1621671 1048144 1176767
4 Faridkot 1288090 1455075 1541971 930521 1032107
5 Fatehgarh Sahib 1207556 1396957 1502861 838150 1030954
6 Ferozpur 1342488 1522111 1618419 956952 1105412
7 Gurdaspur 1318967 1500337 1595284 933323 1042699
8 Hoshiarpur 1299234 1485286 1597500 843123 961297
9 Jalandhar 1339842 1551497 1617018 899607 1040762
10 Khadoor Sahib 1340145 1563256 1638842 946690 1040518
11 Ludhiana 1309308 1561201 1683325 846277 1100457
12 Patiala 1344864 1580273 1739600 935959 1120933
13 Sangrur 1251401 1424743 1529432 931247 1099467
Voters_2019
1 859513
2 1081727
3 1200810
4 974947
5 985948
6 1172033
7 1103887
8 990791
9 1018998
10 1046032
11 1046955
12 1177903
13 1105888
我已经写了代码
data <- read.csv(file = "Punjab data 3.csv")
data
library(ggplot2)
library(reshape2)
long <- reshape2::melt(data, id.vars = "PC_Name")
ggplot(long, aes(PC_Name, value, fill = variable)) + geom_freqpoly(stat="identity",binwidth = 500)
我正在尝试绘制类似this的图形我尝试了折线图和几何线,但是我不确定问题出在哪里。我现在正在尝试geom多边形,但未作图。我想根据2009年2014年2019年比较选民或选民,而不是全部选两个。]
我想在x轴上绘制PC_Name,并将Electors_2009与Voters_2009和Electors_2014与Voters_2014进行比较,所有这些都在同一图形上。因此,在y轴上,融化后我将获得“值”。
我的数据是PC_名称Electors_2009 Electors_2014 Electors_2019 Voters_2009 Voters_2014 1 Amritsar 1241099 1477262 1507875 814503 1007196 2 Anandpur Sahib ...
听起来好像您对水平轴上的PC_Name
和对垂直轴上的value
(熔化后)感兴趣。也许您可能对这样的地标感兴趣,并比较了选民和选民?