使用scatterpie包,需要重新指定输入坐标。 包括两个函数:geom_scatterpie()函数和geom_scatterpie_legend()函数。 (只有能够自己去构建一个包,才算学有突破吧,hhhh) 代码: library(ggplot2)library(scatterpie)library(patchwork)#构造数据set.seed(123)long<-rnorm(50,sd=100)lat<-rnorm(50,sd=50)d<-data.frame...
geom_scatterpie(cols = c("a","b")) + theme_bw() # Error in diff(range(data[, xvar])) : 缺少参数"data",也没有缺省值 一般来说,在ggplot2绘图系统中,ggplot()函数指定的是全局参数,几何图形函数没有指定的参数就会自动继承全局的参数,但从上面的报错来看,scatterpie工具包并没有适配这一特点,因...
ggplot()+geom_scatterpie(data=dat01,aes(x=x,y=y,group=Taxa_Treatment,r=Nt/200),cols=c("G_best(%)","EC_best(%)","G+EC_best(%)"))+scale_fill_manual(values=c("#deebf7","#9ecae1","#3182bd"),name=NULL)+ggnewscale::new_scale_fill()+geom_circle(data=dat02,aes(x0=x,y0...
结合我们做热力地图时的变量和代码,添加上一个新的scatterpie几何映射函数,很容易就写出来下面的代码: ggplot()+ geom_polygon(data=china_heatmap_data,colour="grey40", aes(x=long,y=lat,group=group,fill=ratio))+ scale_fill_gradient(low="white",high="red")+ geom_scatterpie(data=pie_data_com, ...
library(scatterpie)dat2<-data.frame(x=1,y=1,region=1,Core=10331,Softcore=2036,Dispensable=19138,Special=3059)p2<-ggplot()+geom_scatterpie(data=dat2,aes(x,y,group=region,r=1),cols=c("Core","Softcore","Dispensable","Special"),color="black",show.legend=FALSE)+coord_equal()+theme_void...
geom_scatterpie(cols = c("a","b")) + theme_bw() # Error in diff(range(data[, xvar])) : 缺少参数"data",也没有缺省值 1. 2. 3. 4. 一般来说,在ggplot2绘图系统中,ggplot()函数指定的是全局参数,几何图形函数没有指定的参数就会自动继承全局的参数,但从上面的报错来看,scatterpie工具包并没...
geom_scatterpie(),geom_scatterpie_legend()。 由于scatterpie目前不支持sf数据模型, 且下载的中国地图数据包经过fortify()转化后,与业务数据没有公共变量, 故不能合并数据集,只能用2个数据集绘图。 1rm(list = ls()); gc() # 清空内存 2library(ggplot2) ...
geom_scatterpie(data=city_data2,aes(x=jd,y=wd,r=Full),cols=names(city_data2)[2:4],color="grey", alpha=.8) + scale_fill_brewer(guide=FALSE)+ facet_wrap(~Year)+ theme_void() 关于如何分析ggplot2分面气泡图饼图问题的解答就分享到这里了,希望以上内容可以对大家有一定的帮助,如果你还有很...
这里做饼状图使用scatterpie这个R包非常方便 library(ggplot2)library(scatterpie)library(ggpmisc)dfpie<-data.frame(x=1,y=1,A=10,B=15,C=20)p1<-ggplot()+geom_scatterpie(data=dfpie,aes(x=x,y=y,r=1),cols=c("A","B","C"))+coord_equal()+theme_void()+theme(legend.position="none")p1...
结合采样信息和地图信息 city<-read.delim("pie.xls",row.names=1)%>%t()%>%as.data.frame()%>%rownames_to_column(var="city")%>%left_join(.,read.delim("map.xls"),by="city") 绘制地图 geom_scatterpie在地图上添加多个饼图 world_map%>%left_join(.,map,by="country")%>%ggplot()+geom...