我要做的是绘制一个折线图,显示几个国家的比较值。我得到的图表是:
这里的问题是图例中列出了形状和颜色。我希望图例只是该国家/地区的组合(使用形状)和颜色的组合。我正在使用这个位:
ggplot(data=Data,aes(x=Indicator,y=Numeric,group=Country,shape=group,colour=Country))+geom_point()+geom_line()
数据就像这样
Indicator Year Country Numeric data group
1 All causes 2008 Afghanistan 1663 3.22 Very Low
2 All causes 2008 Albania 518 8.53 Low
3 All causes 2008 Algeria 591 8.64 Low
4 All causes 2008 Andorra 310 21.25 High
5 All causes 2008 Angola 1685 10.08 Low
6 All causes 2008 Antigua and Barbuda 682 9.07 Low
7 All causes 2008 Argentina 553 14.38 Medium
8 All causes 2008 Armenia 864 6.62 Very Low
9 All causes 2008 Australia 278 16.76 Medium
10 All causes 2008 Austria 335 16.17 Medium
11 All causes 2008 Azerbaijan 918 4.54 Very Low
12 All causes 2008 Bahamas 629 16.80 Medium
13 All causes 2008 Bahrain 408 11.41 Low
14 All causes 2008 Belgium 369 15.10 Medium
15 All causes 2008 Brazil 667 5.86 Very Low
16 All causes 2008 Costa Rica 400 30.61 Very High
17 All causes 2008 Ivory Coast 2567 6.82 Very Low
18 All causes 2008 Marshall Islands 2681 19.46 High
19 All causes 2008 Netherlands 323 19.69 High
20 All causes 2008 New Zealand 312 19.56 High
有人能指出我可以做些什么来实现这个目标吗?即使我花了很长时间在这上面,我也无法真正打破这一点。
答案 0 :(得分:0)
更改group
- > Country
参数中的shape
。
ggplot(data=Data,aes(x=Indicator,y=Numeric,group=Country,shape=Country,colour=Country))+geom_point()+geom_line()