+3 votes
in Programming Languages by (40.5k 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 (348k points)
selected by
 
Best answer

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

+1 vote
1 answer
+2 votes
1 answer
+3 votes
1 answer
+5 votes
1 answer
asked Sep 25, 2021 in Programming Languages by kush (40.5k points)
+5 votes
1 answer
asked Sep 16, 2021 in Programming Languages by praveen (71.8k points)

...