Hi guys, # I would like to plot a figure with the following layout: # # ---------------------------- # | | | # | | | # | | | # | |--------| # | | | # | | | # | | | # ---------------------------- x <- rnorm(100) y <- rnorm(100) par(fig=c(0,0.7,0,1)) plot(x,y) # (please maximise your plotting device so you get a 'rectangular' area) # now lets do the upper corner 'little' plot par(fig=c(0.7, 1, 0.5, 1)) plot(x,y) # and ... par(fig=c(0.7, 1, 0, 0.5)) plot(x,y) Now, my problem is as you might have seen already, that the old figure gets deleted when the new one is placed. I was trying to reproduce an exercise a saw in an S-plus book. I would really like to know what is going on, the documentation about graphic parameters is not very helpful about fig, and I would really like to set a graph with the above layout. Thanks, Mario dos Reis.
R is not S-PLUS, and you need par(new=TRUE) before calling par(fig) etc. That is probably not an intentional difference. On Mon, 22 Mar 2004, Mario dos Reis wrote:> Hi guys, > > # I would like to plot a figure with the following layout: > # > # ---------------------------- > # | | | > # | | | > # | | | > # | |--------| > # | | | > # | | | > # | | | > # ---------------------------- > > x <- rnorm(100) > y <- rnorm(100) > > par(fig=c(0,0.7,0,1)) > plot(x,y) > > # (please maximise your plotting device so you get a 'rectangular' area) > > # now lets do the upper corner 'little' plot > > par(fig=c(0.7, 1, 0.5, 1)) > plot(x,y) > > # and ... > > par(fig=c(0.7, 1, 0, 0.5)) > plot(x,y) > > Now, my problem is as you might have seen already, that the old figure > gets deleted when the new one is placed. I was trying to reproduce an > exercise a saw in an S-plus book. I would really like to know what is > going on, the documentation about graphic parameters is not very helpful > about fig, and I would really like to set a graph with the above layout. > > Thanks, > Mario dos Reis. > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html > >-- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
On Mon, 2004-03-22 at 10:22, Mario dos Reis wrote:> Hi guys, > > # I would like to plot a figure with the following layout: > # > # ---------------------------- > # | | | > # | | | > # | | | > # | |--------| > # | | | > # | | | > # | | | > # ---------------------------- > > x <- rnorm(100) > y <- rnorm(100) > > par(fig=c(0,0.7,0,1)) > plot(x,y) > > # (please maximise your plotting device so you get a 'rectangular' area) > > # now lets do the upper corner 'little' plot > > par(fig=c(0.7, 1, 0.5, 1)) > plot(x,y) > > # and ... > > par(fig=c(0.7, 1, 0, 0.5)) > plot(x,y) > > Now, my problem is as you might have seen already, that the old figure > gets deleted when the new one is placed. I was trying to reproduce an > exercise a saw in an S-plus book. I would really like to know what is > going on, the documentation about graphic parameters is not very helpful > about fig, and I would really like to set a graph with the above layout. > > Thanks, > Mario dos Reis.Try reading through chapter 12 in An Introduction to R, which covers plotting basics. There are differences between R and S-PLUS. You need to use par(new = TRUE) prior to the second and third plots, otherwise each call to plot() clears the plot device. Use the following: x <- rnorm(100) y <- rnorm(100) par(fig=c(0,0.7,0,1)) plot(x,y) par(new = TRUE) par(fig=c(0.7, 1, 0.5, 1)) plot(x,y) par(new = TRUE) par(fig=c(0.7, 1, 0, 0.5)) plot(x,y) That should get you what you want. Also, take a look at the layout() function (?layout), which enables you to define sections within the overall plotting area as do par("mfcol") and par("mfrow"). HTH, Marc Schwartz
Try: x <- rnorm(100) y <- rnorm(100) par(fig=c(0,0.7,0,1)) plot(x,y) # (please maximise your plotting device so you get a 'rectangular' area) # now lets do the upper corner 'little' plot par(fig=c(0.7, 1, 0.5, 1),new=T) plot(x,y) # and ... par(fig=c(0.7, 1, 0, 0.5),new=T) plot(x,y) -----Original Message----- From: Mario dos Reis [mailto:mario.reis at ucl.ac.uk] Sent: March 22, 2004 12:23 PM To: r-help at stat.math.ethz.ch Subject: [R] Setting the 'fig' graphic parameter Hi guys, # I would like to plot a figure with the following layout: # # ---------------------------- # | | | # | | | # | | | # | |--------| # | | | # | | | # | | | # ---------------------------- x <- rnorm(100) y <- rnorm(100) par(fig=c(0,0.7,0,1)) plot(x,y) # (please maximise your plotting device so you get a 'rectangular' area) # now lets do the upper corner 'little' plot par(fig=c(0.7, 1, 0.5, 1)) plot(x,y) # and ... par(fig=c(0.7, 1, 0, 0.5)) plot(x,y) Now, my problem is as you might have seen already, that the old figure gets deleted when the new one is placed. I was trying to reproduce an exercise a saw in an S-plus book. I would really like to know what is going on, the documentation about graphic parameters is not very helpful about fig, and I would really like to set a graph with the above layout. Thanks, Mario dos Reis. ______________________________________________ R-help at stat.math.ethz.ch mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html