将多个照片拼接到一起,然而电脑上没有安装ps 和 ai (拼图我暂时只想到这两个软件了)
直接使用R语言吧
思路是读取图片
使用ggplot2 显示
最后使用patchwork 拼接
代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
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实现将多个照片拼接到一起的文章就介绍到这了,更多相关R语言ggplot2多照片拼接内容请搜索服务器之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持服务器之家!
原文链接:https://www.jianshu.com/p/8004f71f1929