How to merge two figures in R

Viewed 55

Assumption

I'd like to save and merge the results of scaling and plotting using Thurston's pairwise comparison method into an image using a code such as magick. I'd appreciate your help. Thank you in advance.

What I want to do

I want to merge images from one codes.

Code 1

x <- c(-0.3703, 0.0494, 0.0792, 0.2963, 0.0772, -0.2031, -0.9305, 0.3852, 0.5507, -0.0342)
y <- c(rep(0, 10))
lab <- c("a", "b", "c", "d", "e", "f", "g", "h", "i", "j")
plot(x, y, pch = 19, col = "red")
abline(h = 0)
text(x - 0.01, y + 0.3, lab, adj = 0)

code2

x <- c(-0.7567, -0.1327, 0.4579, 0.5580, 0.5441, -0.1632, -0.7826, 0.1045, 0.8482, -0.4774)
y <- c(rep(0, 10))
lab <- c("a", "b", "c", "d", "e", "f", "g", "h", "i", "j")
plot(x, y, pch = 19, col = "blue")
abline(h = 0)
text(x - 0.01, y + 0.3, lab, adj = 0)

Output result of code 1

enter image description here

Output result of code 2

enter image description here

Ideal output result

enter image description here

Additional information (FW/tool versions, etc.)

iMac M1 2021, R 4.2.0, RStudio

1 Answers

With base R you can try the par() function like this

par(mfrow = c(2,1))
plot(x, y, pch = 19, col = "red")
abline(h = 0)
text(x - 0.01, y + 0.3, lab, adj = 0)

plot(x, y, pch = 19, col = "blue")
abline(h = 0)
text(x - 0.01, y + 0.3, lab, adj = 0)
Related