I'm trying to plot 3 different graphics in the same figure with legend in the right side, like this figure bellow. But I'd like that my legend icon were just lines and not square with lines.
However, I'm doing a total inelegant way to get this figure. I'm plotting the graphics with ggarrange(p1, p2, p3, ncol=2, nrow=2, common.legend = F, legend="none")
, and then I'm pasting the legend in the pdf, using the website Small Pdf.
Here is the code I'm using to get the graphics.
p1=ggplot() +
geom_density(data = df11, aes(x =as.vector(snormal_sim0161[,1])),colour = 'blue',
size = 1.1,show.legend = F) +
geom_density(data = df21, aes(x = as.vector(snormal_sim261[,1])),colour = 'green',
size = 1.1,show.legend = F) +
geom_density(data = df31, aes(x = snormal_sim09[61,]),colour = 'pink',
size = 1.1,show.legend = F) +
stat_function(data = data.frame(x = c(-10, 10)),
aes(x),colour = 'black',fun = skewn, n = 100000,
args = list(xi = 0, omega = 1, alpha= delta.sn), size=1.1) + ylab("") +
coord_cartesian(xlim = c(-3, 3)) +
labs( x = expression(y[r]), y=expression("Densities"))+
theme_bw(base_size = 15)
p2=ggplot() +
geom_density(data = df1, aes(x =as.vector(df11[,1])),colour = 'blue',
size = 1.1,show.legend = F) +
geom_density(data = df2, aes(x =as.vector(df21[,1])),colour = 'green',
size = 1.1,show.legend = F) +
geom_density(data = df3, aes(x = as.vector(df31)),colour = 'pink',
size = 1.1,show.legend = F) +
stat_function(data = data.frame(x = c(-10, 10)), aes(x),colour = 'black',fun = dt, n = 100000,
args = list(df = 2.1), size=1.1) + ylab("") +
coord_cartesian(xlim = c(-4.5, 4.5)) +
labs( x = expression(y[r]), y=expression("Densities"))+
theme_bw(base_size = 15)
p3=ggplot() +
geom_density(data = df13, aes(x = as.vector(df113[,1]),colour = 'PP(0.1)'),
size = 1.1,show.legend = TRUE) +
geom_density(data = df23, aes(x =as.vector(df213[,1]),colour = 'PP(2)'),
size = 1.1,show.legend = TRUE) +
geom_density(data = df33, aes(x = df313,colour = 'PP(10)'),
size = 1.1,show.legend = TRUE) +
stat_function(data = data.frame(x = c(-10, 10)), aes(x,colour = 'Limit distribution'),
fun = skewt, n = 100000,
args = list(xi = 0, omega = 1,nu=2.1, alpha= delta.st), size=1.1) + ylab("") +
coord_cartesian(xlim = c(-4.5, 4.5)) +
scale_colour_manual("",values = c('PP(0.1)'='blue', 'PP(2)'='green', 'PP(10)'='pink','Limit distribution'='black'))+
labs( x = expression(y[r]), y=expression("Densities"))+
theme_bw(base_size = 15)
ggarrange(p1, p2, p3, ncol=2, nrow=2, common.legend = F, legend="none")
So, I'd like to know if there is some way to make the figure above just coding, and how can I change the icons of the legend just to lines.