代码如下:
pca.plot <- read.csv("data.csv",row.names=1, header=T)
Lauraceae <- pca.plot[1:14,]
Fagaceae <- pca.plot[15:20,]
Myrtaceae <- pca.plot[21:27,]
Rubiaceae <- pca.plot[28:37,]
ggplot(Lauraceae, aes(PC1, PC2)) + geom_point(size = 6.0, colour = "#EE1289", shape = 18) + 
  geom_point(data = Fagaceae, size = 5, col = "#1874CD", shape = 16) +
  geom_point(data = Myrtaceae, size = 4.5, col = "#228B22", shape = 15) +
  geom_point(data = Rubiaceae, size = 5, col = "#7EC0EE", shape = 17) +
因为需要指定每个类型点的颜色和性状,所以只好手动一层层加上去,再定义,但是这样画出来的图就不显示图例了,恳请坛友帮助如何显示图例~谢谢!后续还需要添加更多的Family,如果想指定这些Family的点性状颜色,有没有更简单的方法,不用手动一个个添加的?
数据如下:
| Family | PC1 | PC2 | 
| Lauraceae | -0.07802 | 0.281613 | 
| Lauraceae | -0.18107 | 0.378589 | 
| Lauraceae | -0.65634 | -0.36388 | 
| Lauraceae | 0.13175 | 0.012919 | 
| Lauraceae | -0.28589 | -0.36197 | 
| Lauraceae | 0.20609 | 0.198577 | 
| Lauraceae | -0.46091 | 0.11853 | 
| Lauraceae | -0.77426 | 0.357975 | 
| Lauraceae | -0.81335 | 0.099304 | 
| Lauraceae | -0.02209 | -0.64762 | 
| Lauraceae | -0.5823 | -0.0268 | 
| Lauraceae | -0.24159 | -0.67401 | 
| Lauraceae | -0.62573 | 0.370096 | 
| Lauraceae | -0.47904 | 0.312894 | 
| Fagaceae | -0.70432 | -0.10668 | 
| Fagaceae | -0.41688 | -0.62105 | 
| Fagaceae | -0.41807 | -0.44478 | 
| Fagaceae | -1.07812 | 0.231227 | 
| Fagaceae | -0.64854 | -0.3509 | 
| Fagaceae | -0.88722 | -0.06045 | 
| Myrtaceae | 0.12592 | -0.38653 | 
| Myrtaceae | -0.2339 | 0.707437 | 
| Myrtaceae | -0.30893 | -0.01912 | 
| Myrtaceae | -0.3187 | -0.31963 | 
| Myrtaceae | -0.18848 | -0.88771 | 
| Myrtaceae | -0.62694 | -0.69233 | 
| Myrtaceae | -0.26791 | -0.973 | 
| Rubiaceae | -0.20898 | -0.73792 | 
| Rubiaceae | 0.03932 | 0.163706 | 
| Rubiaceae | -0.362 | -0.15984 | 
| Rubiaceae | 0.84551 | 0.329486 | 
| Rubiaceae | 0.24983 | -0.38807 | 
| Rubiaceae | 0.77355 | 0.346762 | 
| Rubiaceae | 0.19266 | -0.19431 | 
| Rubiaceae | 0.19393 | 0.024911 | 
| Rubiaceae | 0.4097 | 0.081883 | 
| Rubiaceae | 0.46633 | -0.41123 | 
  
