我想用质心位置创建几个条形图来定位它们。我已经有一个多边形的绘图代码,我想把它们组合起来。这些都是平面图,而不是世界各地的地理区域。不幸的是,我在下面的例子中有几个要点。如何使用ggplot2来覆盖我所有的点?下面是我要添加条形图的示例ggplot代码:
ggplot() + theme_minimal()+ theme(plot.title = element_text(hjust = 0.5,face="bold",size=14),line=element_line(size=0.2),
panel.grid.major = element_blank(), panel.grid.minor = element_blank(),
axis.text.x=element_blank(),axis.text.y=element_blank(),strip.text = element_text(size=11, face = "bold"),axis.title.x = element_blank(),
axis.title.y = element_blank(),legend.title=element_text(size=9, face = "bold"))+
geom_polygon(aes(x =long, y = lat, group = group), size=0.5,color="black",fill="black",alpha=0.2, data =shp1_data.frame)+
geom_polygon(aes(x =long, y = lat, group = group), size=0.5,color="white",fill="black",alpha=0.2, data =shp4_data.frame)
Codes for the image attached
head(read.table("Sampledata.txt",header=T),15)
Location_i variable value x y
1 A005 Head 0.0000000 1238.509 -970.4791
2 A005 Hair 0.0000000 1238.509 -970.4791
3 A005 Knees 0.1666667 1238.509 -970.4791
4 A005 Ears 0.0000000 1238.509 -970.4791
5 A005 Heart 0.0000000 1238.509 -970.4791
6 A005 Mouth -0.1666667 1238.509 -970.4791
7 A005 Toes 0.0000000 1238.509 -970.4791
8 A028 Head 0.0000000 1538.509 -870.4791
9 A028 Hair 0.0000000 1538.509 -870.4791
10 A028 Knees 0.0000000 1538.509 -870.4791
11 A028 Ears 0.0000000 1538.509 -870.4791
12 A028 Heart 1.0000000 1538.509 -870.4791
13 A028 Mouth -1.0000000 1538.509 -870.4791
14 A028 Toes 0.0000000 1538.509 -870.4791
15 A030 Toes 0.0000000 1738.509 -870.6731
我放了一个数据样本
Here in my drive
使用x和y位置字段,value,变量ad location ID。绘图使用变量字段围绕每个质心(位置_i)分组。
##To read in the text file after downloading
A1<-read.table("Sampledata.txt",header=T)