I want to create a graph like below but with a custom legend by group. I have two samples names A and B and a target (Y) associated. what I want is to group the legend with one side :
sample A : true vs obs
and other side
sample B : true vs obs
with the corresponding shape and color.
Below, this is what I already had.
library(ggplot2)
sites = rep(seq(0.55,0.58,0.01), times = 4)
sites = sort(sites)
org = rep(c("Y_A", "Y_A_obs", "Y_b", "Y_b_obs"), times = 4)
values = rnorm(16)
df = data.frame(sites = sites, origine = org, values = values)
ggplot(df, aes(x=sites, y=values, color=origine)) +
geom_point(aes(shape=origine, color=origine), size=3)+
scale_shape_manual(values=c(0, 15, 2, 17))+
scale_color_manual(values=c("blue", "purple", "red", "orange"))
Thanks for any help !


