R語言ggplot2實現(xiàn)將多個照片拼接到一起
更新時間:2021年07月13日 09:05:47 作者:小明的數(shù)據分析筆記本
本文主要介紹了R語言ggplot2實現(xiàn)將多個照片拼接到一起,文中通過示例代碼介紹的非常詳細,需要的朋友們下面隨著小編來一起學習學習吧
將多個照片拼接到一起,然而電腦上沒有安裝ps 和 ai (拼圖我暫時只想到這兩個軟件了)
直接使用R語言吧
思路是讀取圖片
使用ggplot2 顯示
最后使用patchwork 拼接
代碼
library(ggplot2)
library(jpeg)
library(ggpubr)
library(patchwork)
img0<-readJPEG("308/0.JPG")
p0<-ggplot()+
background_image(img0)+
theme_void()
img1<-readJPEG("308/1.JPG")
p1<-ggplot()+
background_image(img1)+
theme_void()
img2<-readJPEG("308/2.JPG")
p2<-ggplot()+
background_image(img2)+
theme_void()
img3<-readJPEG("308/3.JPG")
p3<-ggplot()+
background_image(img3)+
theme_void()
img4<-readJPEG("308/4.JPG")
p4<-ggplot()+
background_image(img4)+
theme_void()
p1234<-p1+p2+p3+p4+plot_layout(ncol = 4)
img5<-readJPEG("308/5.JPG")
p5<-ggplot()+
background_image(img5)+
theme_void()
img6<-readJPEG("308/6.JPG")
p6<-ggplot()+
background_image(img6)+
theme_void()
img7<-readJPEG("308/7.JPG")
p7<-ggplot()+
background_image(img7)+
theme_void()
img8<-readJPEG("308/8.JPG")
p8<-ggplot()+
background_image(img8)+
theme_void()
p5678<-p5+p6+p7+p8+plot_layout(ncol=4)
p_final<-p0+p1234+p5678+plot_layout(ncol=1,nrow=3,
heights = c(3,1,1))
ggsave(filename="p-2.jpeg",
p_final,
width=12,
heigh=15,
dpi = 1000)
到此這篇關于R語言ggplot2實現(xiàn)將多個照片拼接到一起的文章就介紹到這了,更多相關R語言ggplot2多照片拼接內容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!

