-1

I have 10 time series, I want to draw their graphs, and then combine them (so that there are 5 rows and 2 columns). so that the name doesn’t have on the axis y, but it is on the top of the graph and each graph has a grid.

did it but it doesn't work

layout(matrix(c(1,2,3,4,5,6), 3, 2, byrow = TRUE)) 
plot(CPI, xlab ="data",main="Scatterplot of wt vs. mpg") 
plot(industry_prod, main="Scatterplot of wt vs disp") 
plot(m2, main="Scatterplot of wt vs. mpg") 
plot(interbank_rate, main="Scatterplot of wt vs disp") 
plot(ex_rate, main="Scatterplot of wt vs. mpg") 
plot(unempl_rate, main="Scatterplot of wt vs disp")
grid()
r2evans
  • 141,215
  • 6
  • 77
  • 149
Alina
  • 1
  • 2
  • Please make this question *reproducible*. This includes sample code you've attempted (including listing non-base R packages, and any errors/warnings received), sample *unambiguous* data (e.g., `dput(head(x))` or `data.frame(x=...,y=...)`), and intended output. Refs: https://stackoverflow.com/q/5963269, [mcve], and https://stackoverflow.com/tags/r/info. – r2evans May 26 '20 at 20:36
  • Alina, I suspect that this can be handled better with some faceting plot mechanism, such as `ggplot2` and its `facet_grid` framework. Without data or a semblance of what it looks like, it's difficult to know for sure or make a suggestion. Your sample code has six different objects (`CPI`, `m2`, ...), it might be easier to use different columns from R's `datasets::` package to demonstrate your point without clobbering the question with hundreds of rows of disparate data. – r2evans May 26 '20 at 21:06

1 Answers1

0

That is it can be done in plain R.

old.par <- par(mfrow=c(3, 2)) # this statement is necessary to restore the setting later

plot(CPI, xlab ="data",main="Scatterplot of wt vs. mpg") 
plot(industry_prod, main="Scatterplot of wt vs disp") 
plot(m2, main="Scatterplot of wt vs. mpg") 
plot(interbank_rate, main="Scatterplot of wt vs disp") 
plot(ex_rate, main="Scatterplot of wt vs. mpg") 
plot(unempl_rate, main="Scatterplot of wt vs disp")

par(old.par) # restore previous setting (so that you can do single plots again)
Jan
  • 4,974
  • 3
  • 26
  • 43