Building 3 graphs in layout 2-1 in R

Is it possible to get 3 graphs in one figure in R with distribution, as shown in the figure below? The graphs should be the same width, and the graph C should be centered.

-----   -----
| A |   | B |
-----   -----
    -----
    | C |
    -----

Thank!

+4
source share
1 answer

Yes, with a function layout(...).

layout(matrix(c(1,2,3,3), 2, 2, byrow = TRUE))
hist(mtcars$wt)
hist(mtcars$mpg)
hist(mtcars$disp)

So, it layout(...)takes a matrix, where each element corresponds to a chart number. In this case, [1,1] corresponds to the first schedule, [1,2] corresponds to the second schedule, and [2,1: 2] corresponds to the third schedule.

This example is taken with a slight modification here .

, "", , .

par(mar=c(4,4,2,2))
layout(matrix(c(1,2,3,3), 2, 2, byrow = TRUE))
hist(mtcars$wt)
hist(mtcars$mpg)
par(mar=c(2,14,2,14))
hist(mtcars$disp)

+5

Source: https://habr.com/ru/post/1544655/


All Articles