+3 votes
in Programming Languages by (16.2k points)
I want to combine a couple of plots that were not created using ggplot in one plot. Is there any R function to put them in one plot as subplots?

1 Answer

+2 votes
by (51.1k points)

You can use the par() function to combine multiple plots into one plot. par can be used to set or query graphical parameters.

In the par() function, you need to include the option "mfrow=c(nrows, ncols)" to specify the number of rows and columns in the plot.

Here is an example of generating a plot with 1 row and 2 columns to combine two plots.
attach(mtcars)
par(mfrow=c(1,2))
plot(wt,mpg, main="plot1")
plot(wt,disp, main="plot2")
The above code generates the following plot:
combine plots in r using par()

Related questions

+5 votes
1 answer
asked Sep 25, 2021 in Programming Languages by kush (16.2k points)
+5 votes
1 answer
asked Sep 16, 2021 in Programming Languages by praveen (21.4k points)
+5 votes
1 answer
+3 votes
1 answer
+5 votes
1 answer

...