I want to compare two variables against the X axis by displaying them on the same column.
For some reasons (not technical question), I can’t display both variables on the same graph.
When I display these two variables with different unit ranges with ggarrange, the one with the largest numbers appears to have more space for y labels and less space for the graph (lower abscissa size).
Do you know how I could display both graphs having the same greyzone size (same abscissa size)?
Thank you
### Import library
library(ggplot2)
library(ggpubr)
### Initiating data
dfTemp <-
data.frame(
Xaxis=1:100,
Variable1=rnorm(100, 100, 10),
Variable2=rnorm(100, 1000000, 100000)
)
### Initiating plots
scatterPlot1 <-
ggplot(data=dfTemp, aes(x=Xaxis, y=Variable1)) +
geom_line()
scatterPlot2 <-
ggplot(data=dfTemp, aes(x=Xaxis, y=Variable2)) +
geom_line()
### Display plots
ggarrange(scatterPlot1,
scatterPlot2,
nrow=2, ncol=1)
>Solution :
Use the align argument
dfTemp <-
data.frame(
Xaxis=1:100,
Variable1=rnorm(100, 100, 10),
Variable2=rnorm(100, 1000000, 100000)
)
### Initiating plots
scatterPlot1 <-
ggplot(data=dfTemp, aes(x=Xaxis, y=Variable1)) +
geom_line()
scatterPlot2 <-
ggplot(data=dfTemp, aes(x=Xaxis, y=Variable2)) +
geom_line()
### Display plots
ggarrange(scatterPlot1,
scatterPlot2,
nrow=2, ncol=1, align = "v")

