Split.Screen Function In R
2
1
Entering edit mode
12.8 years ago

Dear All,

I ran into some problem while I was trying to visualise some data. Essentially I wrote a script in R which generates a pdf(a plot actually) for each of the gene that I am interested in. The pdf file has 2 panels.

To make these two panels, I split my screen first of all with the following command: split.screen( figs = c( 2, 1 ) ) ### Split my screen into 2 parts such that there is 1 column and two rows. Then, I just go about doing things in panel 1 and panel 2. For panel 1, I have to write the code under screen(1) while for panel 2, the code begins with screen(2). Everything works fine. My only issue is that I want to split the screen into unequal sizes. I would like panel 1 (screen 1) to occupy 70% of the final image and screen 2/panel 2 to occupy the rest. Any suggestions on how do I make changes to the split.screen command at the beginning ?

Thanks

r • 9.7k views
ADD COMMENT
6
Entering edit mode
12.8 years ago

Try the layout() function, which will give you all sort of fine-grained control over where your plots go and how they're spaced:

For one example: http://stackoverflow.com/questions/3638773/r-add-extra-spacing-between-a-subset-of-plots

ADD COMMENT
0
Entering edit mode

Thanks Chris for the info on the layout function, though I stil managed to get it done by supplying a matrix to the split.screen function as suggested by "sgibb".

ADD REPLY
4
Entering edit mode
12.8 years ago
Sgibb ▴ 40

Please see ?split.screen section Arguments/figs for details:

coord <- matrix(c(c(0, 1, 0, 0.7), c(0, 1, 0.7, 1)), byrow=T, ncol=4)
split.screen(coord)
screen(1)
plot(1:10)
screen(2)
plot(1:10)
ADD COMMENT
0
Entering edit mode

Thanks, the split.screen with the modification that you suggested worked fine.

ADD REPLY

Login before adding your answer.

Traffic: 2739 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6