Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Split screen (with unequal windows) plotting in R

Tags:

plot

r

I know I can use par(mfrow=c(1, 2)) to create a plot with a split screen. However, I'd really like to create a plot where 2/3 of the window is used to plot one graph, and 1/3 of the window is used to plot another. Is this possible?

like image 890
random_forest_fanatic Avatar asked Dec 04 '12 13:12

random_forest_fanatic


2 Answers

You need to use function layout instead of par here, with argument widths:

layout(matrix(c(1,2),nrow=1), widths=c(2,1))

See ?layout for more informations.

like image 101
plannapus Avatar answered Nov 04 '22 13:11

plannapus


alternatively:

a  <-  c(1:10)
b  <-  c(1:10)

par(fig=c(0, (2/3), 0, 1))
par(new=TRUE)
plot(a, b)
par(fig=c((2/3), 1, 0, 1))
par(new=TRUE)
plot(a, b)
like image 45
thijs van den bergh Avatar answered Nov 04 '22 14:11

thijs van den bergh