geom_point(shape = 24,size = 6,fill = "red") + geom_point(shape = 24,size = 6,fill = "black", position = position_nudge(x = 0.5, y = 0.1)) 图中红色为默认位置,黑色为平移点。position_nudge()和geom_text()结合使用可以在图形附近统一添加文字: df <- data.frame(x = c(1,3,2,...
ggplot(singer, aes(x=height, fill=voice.part)) +geom_density() + facet_grid(voice.part~.) 创建一个包含刻面和分组的图 ggplot(Salaries, aes(x=yrs.since.phd, y=salary, color=rank,shape=rank)) + geom_point() +facet_grid(.~sex) 6 添加光滑曲线 ggplot2包包含了一系列计算统计的函数来加...
ggplot(heightweight,aes(x=ageYear,y=heightIn,fill=weightLb))+geom_point(shape=21,size=2.5)+ scale_fill_gradient(low="black",high = "white") 1. 2. 若想修改右边的图例,可以使用guide_legend(),改为离散型的图例 ggplot(heightweight,aes(x=ageYear,y=heightIn,fill=weightLb))+geom_point(shap...
geom_point(position = 'jitter',color='blue',alpha=0.5)+ geom_rug(color='orange') + #添加地毯图 stat_summary(fun.y = 'mean',geom = 'point',shape=23,size=3, fill='red') #向箱线图添加均值标记 #1.5绘制单组数据箱线图 #必须给定x参数映射任意一个值 ggplot(birthwt,aes(x=1,y=bwt)...
ggplot(data = mtcars,aes(x = wt,y = mpg,col = vs_f,shape = am_f))+ geom_point()+ theme_classic() 1. 2. 3. 4. 3.分面 - 刻面图 一个图变成多个并列的图,刻面图函数有: facet_wrap(~var,ncol = n),将每个var水平排列成n列的独立图; ...
R语言自带的点的形状 library(ggsci)ggplot(data=small_diamonds,aes(x=carat,y=price))+geom_point(shape=21,size=5,color="black",aes(fill=cut))+scale_fill_npg()+theme_classic() 点的大小 ggplot(data=small_diamonds,aes(x=carat,y=price))+geom_point(shape=21,color="black",aes(fill=cut,si...
如下(注:class、drv、cyl等是数据集中的类别名称):- aes(displ, hwy, colour = class)- aes(displ, hwy, shape = drv)- aes(displ, hwy, size = cyl)因此,增加一个颜色参数,将class变量映射成不同的颜色,并创建图例,脚本如:ggplot(mpg, aes(displ, hwy, colour = class)) + geom_point()
2,aes(x=x,y=y,fill=group,color=group))+ geom_point(shape=22,size=5)+ scale_fill_manual(values = c("#fc8072","#a1d99b", "#4192c6"), labels=c("Reference homozygous", "Heterozygous", "Alternate homozygous"))+ scale_color_manual(values = c("#fc8072","#a1d99b", "#4192c6")...
mypoint=geom_point(size=3,shape=21,colour="#003087",fill="white") mybar=geom_bar(fill="#0C8DC4",stat="identity") #然后是配色,考虑到样本的多样性,可以事先设定颜色,如3种颜色或7种颜色的组合 mycolour_3<-scale_fill_manual(values=c("#085A9C","#EF0808","#526373")) ...
ggplot(dsmall,aes(carat,price))+geom_point(aes(shape=cut))+scale_shape_manual(name='diamonds cut',values = c(1:5)) #1:5和基础绘图包中的形状是一一对应的 3. 点的大小 scale_size函数设置点的大小 p<-ggplot(mpg,aes(displ,hwy,size=hwy))+geom_point()p+scale_size(name='hwy size',break...