So far, I have constructed a plot like this, but rather than 3 groupings there are quite a bit more. For now, this is just for illustration. I have made something like this:
#### Load Libraries ####
library(tidyverse)
library(ggpubr)
library(magick)
#### Create Main Plot ####
main <- iris %>%
ggplot(aes(x=Petal.Width,
y=Petal.Length,
color=Species))+
geom_point()+
geom_smooth(method = "lm")+
theme(legend.position = "bottom")+
labs(x="Frink Width",
y="Frink Height",
color="Frink Type")+
scale_color_manual(labels = c("Frink1","Frink2","Frink3"),
values = c("lightblue","steelblue","navyblue"))
main
#### Import Image ####
imp <- frink <- image_read("https://jeroen.github.io/images/frink.png")
imp
#### Create Images as Plots ####
p1 <- image_ggplot(imp)+
labs(title = "Frink 1")
p2 <- image_ggplot(imp)+
labs(title = "Frink 2")
p3 <- image_ggplot(imp)+
labs(title = "Frink 3")
#### Arrange ####
ps <- ggarrange(p1,p2,p3,
ncol = 1)
ps
##### Smash Together ####
ggarrange(main,ps)
Which gives me a regular scatter on the left, and three images on the right:
The main thing I want to try to accomplish is to somehow move the color labels ("Frink1" and so on) to the right underneath each picture. How do I accomplish this? Keep in mind that for my specific purpose, the entire right region is filled with pictures, so this will have to be done for more than just these three in my case.
Perhaps the easiest way to do this is create a legend with each image plot:
p1 <- image_ggplot(imp) +
geom_line(data = data.frame(x = 1:2, y = 1:2), aes(x, y, color = 'Frink1')) +
scale_color_manual(NULL, values = "lightblue") +
theme(legend.position = 'bottom')
p2 <- image_ggplot(imp)+
geom_line(data = data.frame(x = 1:2, y = 1:2), aes(x, y, color = 'Frink2')) +
scale_color_manual(NULL, values = "steelblue") +
theme(legend.position = 'bottom')
p3 <- image_ggplot(imp) +
geom_line(data = data.frame(x = 1:2, y = 1:2), aes(x, y, color = 'Frink3')) +
scale_color_manual(NULL, values = "navyblue") +
theme(legend.position = 'bottom')
ps <- ggarrange(p1,p2,p3,
ncol = 1)
ps
ggarrange(main,ps)