I have total 7 plots. Six of them are line charts which are to be aligned and arranged one below each other such that there is no space between them - to make one composite plot.
Here is the data and ggplot2 code and I am using the same line chart 6 times just to explain my problem
x<- 1:10
y<- rnorm(10)
data <- data.frame(x,y)
library(ggplot2)
k<- ggplot(data, aes(x= x, y= y)) + geom_line() + theme(panel.background=element_blank()) + theme(aspect.ratio = 0.15) + theme(panel.grid.minor = element_blank(), panel.grid.major = element_blank(), axis.line.x = element_line(colour = "black", size= 0.5), axis.line.y = element_line(colour = "black", size= 0.5), axis.ticks.y = element_line(colour = "black", size= 0.5), axis.ticks.x = element_blank()) + xlab(label = "")+ ylab(label = "") + scale_x_continuous(label= NULL) +theme(plot.margin = unit(c(-0.25, 2, -0.25, 2), "cm"))
k
Seventh is scatter plot with regression line
a<- 1:10
a
b<- 11:20
b
data1 <- data.frame(a,b)
data1
library(ggplot2)
k3<-ggplot(data1, aes(x=a, y=b))+ geom_point(shape=1, fill ="black", alpha= 1, color= "black", size=3) + geom_smooth(method = lm, size = 0.5, linetype ="dotted", fill ="black", color= "black", alpha = 0.3)
k3
k3<- k3 + expand_limits(x = c(0.5, 10.5), y = c(10.5,20.5)) + scale_x_continuous(expand = c(0, 0), breaks = c(2,4, 6, 8, 10)) + scale_y_continuous(expand = c(0, 0),breaks = c(10, 12, 14, 16, 18, 20))
k3
k3 <- k3 + theme(panel.background=element_blank())+ theme(aspect.ratio = 1) + theme(panel.grid.minor = element_blank(), panel.grid.major = element_blank(), axis.line.x = element_line(colour = "black"), axis.line.y = element_line(colour = "black", size= 0.5), axis.ticks.y = element_line(colour = "black", size= 0.5), axis.ticks.x = element_line(colour = "black", size= 0.5))
k3
k3<- k3 + scale_x_reverse(expand = c(0, 0))
k3
#Flip axes
k3<- k3 + coord_flip()
k3<- k3 + theme(plot.margin = unit(c(0, 0, 0, 0), "cm"))
k3
I want to arrange (1) composite plot (on left) and (2) scatter plot (on right)side by side. So I tried arranging that way using (1) ggarrange() [in ggpubr] and (2) plot_grid()[in cowplot], but I couldn't.
Could anybody help? Thankyou!
I want the layout to look like this
ggarrange
? – atsyplenkov