在有了以上绘图细节调整的基础后,我们可以来尝试一下用ggplot2绘制火山图: 1.首先载入绘图数据: 完整代码查看【谱度众合】微信公众号走进R语言丨系列4:ggplot作图(二) 2.火山图事实上就是点图根据不同分组上色后绘制的,所以我们直接使用ggplot2中的geom_point()函数配合scale函数进行绘制: 完整代码查看【谱度...
geom_point函数 在ggplot2包中,geom_point()函数用于绘制散点图。通过设置参数size可以调整点的大小。下面是一个简单的示例代码: ```R library(ggplot2)#创建示例数据data <- data.frame( x = c(1, 2, 3, 4, 5), y = c(2, 4, 6, 8, 10), size = c(1, 2, 3, 4, 5) )#绘制散点图g...
ggplot()+ geom_point(data=fig1a, aes(x=log2(FC_Replicate_1), y=log2(FC_Replicate_2)), size=10, shape=21, fill="#f1f1f1", color="black")+ theme_bw()+ geom_point(data=fig1adf, aes(x=log2(FC_Replicate_1), y=log2(FC_Replicate_2), fill=Gene), size=10, shape=21) imag...
> plot3 <- ggplot(iris,aes(x = Sepal.Length,y = Sepal.Width))+ theme_classic(base_size = 9)+ geom_point(shape = 17)+ geom_density_2d(linemitre = 5)+ theme(plot.title = element_text(hjust = 0.5))+ ggtitle("2-dimentional Density 二维密度曲线") > plot3 1.4Violin 小提琴图 > ...
ggplot(Arthritis,aes(x=Treatment,fill=Improved))+ geom_bar(position = 'dodge') #复杂一点(调整图例位置) opar<-par(no.readonly=T) par(mar=c(5,5,4,2)) #自定义图形边界,默认c(5,4,4,2) par(las=2) #定义标签垂直于坐标轴 par(cex.axis=0.75) #定义坐标轴文字缩放倍数 ...
geom_point(pch=17,color="blue",size=2)+ # ggplot()函数没有自己的图形输出。使用几何函数(geom)添加几何对象 # geom_point()函数绘制散点图,使用2倍大小的蓝色三角符号(pch=17) geom_smooth(method ="lm",color="red",linetype=2)+ # geom_smooth()函数绘制平滑曲线,绘制一条线性拟合(method ="lm...
library(ggplot2)data(mtcars)ggplot(mtcars,aes(wt,mpg))+geom_point(size=6,shape=1) image.png 为方便查阅不同点性状对应的参数,书籍中整理了该内容,需要的可以对应点的性状自己设置,需要注意的是第21-25号为具有填充色的符号,如若修改点的边界色和填充色,可以在函数geom_point()中设置点的性状shape=21,...
fig1a.dat%>%filter(Compartment=="Root")%>%ggplot(aes(x=CAP1,y=CAP2))+geom_point(aes(fill=Treatment),shape=22,size=5,color="gray",alpha=0.8)+stat_ellipse(aes(group=Treatment),size=0.5,level=0.95,show.legend=F,lty="dashed")+labs(x="CAP1 (22.6%)",y="CAP2 (6.8%)")+theme_bw...
<GEOM_FUNCTION>:为画图函数,可以使用不同类型的函数图如:点图 geom_point,箱线图geom_boxplot等。 <MAPPINGS>:画图的参数如横、纵坐标,图形映射等属性。 ggplot(data=iris)+geom_point(mapping=aes(x=Sepal.Length,y=Petal.Length))##iris替换<DATA>,geom_point替换<GEOM_FUNCTION>,<MAPPINGS>为映射:x,y...
ggplot(data=df,aes(x=`mean Protection Score [a.u.]`, y=`mean Colonization [log10(CFU/mg)]`))+ geom_point(aes(color=Phylum))+ geom_smooth(method = "lm", formula = "y~x", se=F, color="grey")+ ggsave(filename = "fig3c.pdf", width = 6, height = 4, family="serif") ...