一、地图
library(ggplot2)
data<-read.table("C:/Users/steph/Desktop/visual/data.csv",sep=",",header=TRUE)
city<-read.table("C:/Users/steph/Desktop/visual/region.csv",sep=",",header=TRUE)
head(data,5)
region price lon lat
1 南沙区 13000 113.4461 22.74067
2 南沙区 13000 113.4504 22.73769
3 南沙区 13000 113.4535 22.72865
4 南沙区 13000 113.4557 22.72709
5 南沙区 13000 113.4571 22.72579
head(city,5)
region lon lat
1 从化区 113.5931 23.55400
2 增城区 113.8175 23.26669
3 黄埔区 113.4870 23.18759
4 天河区 113.3685 23.13049
5 荔湾区 113.2254 23.11242
p<-ggplot(data,aes(x=lon, y=lat))+geom_polygon(aes(fill=price, group=region))
p1<-p+scale_fill_gradient(high="darkgreen",low="lightgreen")
p2<-p1+geom_text(aes(x=lon,y=lat,label=region),family="GB1",data=city)
p2
二、维恩图
library(VennDiagram)
A<-1:50
B<-c(30:60,100:120)
C<-c(50:70,110:130)
Length_A<-length(A)
Length_B<-length(B)
Length_C<-length(C)
Length_AB<-length(intersect(A,B))
Length_BC<-length(intersect(B,C))
Length_AC<-length(intersect(A,C))
Length_ABC<-length(intersect(intersect(A,B),C))
T1<-venn.diagram(list(A=A,B=B),filename=NULL,lwd=1,lty=2,col=c('red','blue'),fill=c('red','blue'),cat.col=c('red','blue'),rotation.degree=90)
grid.draw(T1)
T2<-venn.diagram(list(A=A,B=B,C=C),filename=NULL,,lwd=1,lty=2,col=c('red','green','blue'),fill=c('red','green','blue'),cat.col=c('red','green','blue'),reverse=TRUE)
grid.draw(T2)