I would rather use facet_wrap() instead of multiplot()

Just combine all your data in one data.frame and make sure that you have a 
variable indication the iteration.

library(reshape2)
volcano3d <- melt(volcano)
names(volcano3d) = c("x", "y", "z")
volcano3d <- merge(volcano3d, data.frame(Iteration = 1:4))
volcano3d$z <- rnorm(nrow(volcano3d), mean = volcano3d$z, sd = 2)

library(ggplot2)
ggplot(volcano3d, aes(x, y, z = z)) + stat_contour(aes(colour = ..level..)) + 
facet_wrap(~Iteration)



ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature and 
Forest
team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance
Kliniekstraat 25
1070 Anderlecht
Belgium
+ 32 2 525 02 51
+ 32 54 43 61 85
[email protected]
www.inbo.be

To call in the statistician after the experiment is done may be no more than 
asking him to perform a post-mortem examination: he may be able to say what the 
experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ Roger Brinner

The combination of some data and an aching desire for an answer does not ensure 
that a reasonable answer can be extracted from a given body of data.
~ John Tukey


-----Oorspronkelijk bericht-----
Van: [email protected] [mailto:[email protected]] Namens 
Jose Iparraguirre
Verzonden: donderdag 8 november 2012 16:52
Aan: Loukia Spineli; [email protected] help
Onderwerp: Re: [R] A panel of contour plots through a iteration process

Hi Loukia,

I think the problem stems from the fact that the filled.contour "uses the 
layout function and so is restricted to a full page display" as its 
documentation reads. And if you look at the documentation of the layout 
function, it says that it is "totally incompatible with the other mechanisms 
for arranging plots on a device: par(mfrow), par(mfcol)".

However, you can use the ggplot2 package along with the function multiplot, 
which you can find here: 
http://wiki.stdout.org/rcookbook/Graphs/Multiple%20graphs%20on%20one%20page%20(ggplot2)/

It works fine with contour plots.

You need to create your 11 contour plots first.
For example, to keep things simple, let's create 11 equal contour plots:

> library(reshape2)
> volcano3d = melt(volcano)
> names(volcano3d) = c("x", "y", "z")
> library(ggplot2)

> p1 = ggplot(volcano3d, aes(x, y, z = z))+
+  stat_contour(aes(colour = ..level..))
> p2 = ggplot(volcano3d, aes(x, y, z = z))+
+  stat_contour(aes(colour = ..level..))
> p3= ggplot(volcano3d, aes(x, y, z = z))+
+  stat_contour(aes(colour = ..level..))
> p4 = ggplot(volcano3d, aes(x, y, z = z))+
+  stat_contour(aes(colour = ..level..))
> p5 = ggplot(volcano3d, aes(x, y, z = z))+
+  stat_contour(aes(colour = ..level..))
> p6 = ggplot(volcano3d, aes(x, y, z = z))+
+  stat_contour(aes(colour = ..level..))
> p7 = ggplot(volcano3d, aes(x, y, z = z))+
+  stat_contour(aes(colour = ..level..))
> p8 = ggplot(volcano3d, aes(x, y, z = z))+
+  stat_contour(aes(colour = ..level..))
> p9 = ggplot(volcano3d, aes(x, y, z = z))+
+  stat_contour(aes(colour = ..level..))
> p10 = ggplot(volcano3d, aes(x, y, z = z))+
+  stat_contour(aes(colour = ..level..))
> p11 = ggplot(volcano3d, aes(x, y, z = z))+  stat_contour(aes(colour =
> ..level..))

and then run the multiplot function:

> multiplot(p1, p2, p3, p4, p5,p6,p7,p8,p9,p10,p11, cols=2) # the plots will be 
> displayed along two columns.

With so many plots in one page, you'll need to work on the individual margins 
of each plot and the size of the legends, etc, though!

Hope this helps,

José

José Iparraguirre
Chief Economist
Age UK

T 020 303 31482
E [email protected]
Twitter @jose.iparraguirre@ageuk


Tavis House, 1- 6 Tavistock Square
London, WC1H 9NB
www.ageuk.org.uk | ageukblog.org.uk | @ageukcampaigns


For a copy of our new Economic Monitor and the full Chief Economist's report, 
visit the Age UK Knowledge Hub 
http://www.ageuk.org.uk/professional-resources-home/knowledge-hub-evidence-statistics/


For evidence and statistics on the older population, visit the Age UK Knowledge 
Hub 
http://www.ageuk.org.uk/professional-resources-home/knowledge-hub-evidence-statistics/



-----Original Message-----
From: [email protected] [mailto:[email protected]] On 
Behalf Of Loukia Spineli
Sent: 08 November 2012 13:11
To: [email protected] help
Subject: [R] A panel of contour plots through a iteration process

Dear all,

as you can see from the code I want to create *a panel of 11 contour plots 
through a iteration process*. I found a thread that address the issue of 
plotting many contour.plots in the same device, but it does not address my 
problem!
I emphasize that the 11 contour plots must be appeared in the same device 
through an iteration process and NOT individually!

par(mfrow=c(4,3)) # I want them to appear like a 4*3 matrix for(i in 1:11){
p[i]]<-matrix(p[[i]],nrow=l10ncol=length10,byrow=T)
filled.contour(p[i]], etc,etc...)
}
par(mfrow=c(1,1))

Any suggestions would be really appreciated! Thank you very much in advance!!

All the best,
Loukia

        [[alternative HTML version deleted]]

______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Wrap Up & Run 10k next March to raise vital funds for Age UK

Six exciting new 10k races are taking place throughout the country and we want 
you to join in the fun! Whether you're a runner or not, these are events are 
for everyone ~ from walking groups to serious athletes. The Age UK Events Team 
will provide you with a training plan to suit your level and lots of tips to 
make this your first successful challenge of 2012. Beat the January blues and 
raise some vital funds to help us prevent avoidable deaths amongst older people 
this winter.


Sign up now! www.ageuk.org.uk/10k

Coming to; London Crystal Palace, Southport, Tatton Park, Cheshire Harewood 
House, Leeds,Coventry, Exeter


Age UK Improving later life
www.ageuk.org.uk




-------------------------------
Age UK is a registered charity and company limited by guarantee, (registered 
charity number 1128267, registered company number 6825798).
Registered office: Tavis House, 1-6 Tavistock Square, London WC1H 9NA.

For the purposes of promoting Age UK Insurance, Age UK is an Appointed 
Representative of Age UK Enterprises Limited, Age UK is an Introducer Appointed 
Representative of JLT Benefit Solutions Limited and Simplyhealth Access for the 
purposes of introducing potential annuity and health cash plans customers 
respectively.  Age UK Enterprises Limited, JLT Benefit Solutions Limited and 
Simplyhealth Access are all authorised and regulated by the Financial Services 
Authority.
------------------------------

This email and any files transmitted with it are confidential and intended 
solely for the use of the individual or entity to whom they are addressed. If 
you receive a message in error, please advise the sender and delete immediately.

Except where this email is sent in the usual course of our business, any 
opinions expressed in this email are those of the author and do not necessarily 
reflect the opinions of Age UK or its subsidiaries and associated companies. 
Age UK monitors all e-mail transmissions passing through its network and may 
block or modify mails which are deemed to be unsuitable.

Age Concern England (charity number 261794) and Help the Aged (charity number 
272786) and their trading and other associated companies merged on 1st April 
2009.  Together they have formed the Age UK Group, dedicated to improving the 
lives of people in later life.  The three national Age Concerns in Scotland, 
Northern Ireland and Wales have also merged with Help the Aged in these nations 
to form three registered charities:
Age Scotland, Age NI, Age Cymru.










______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
* * * * * * * * * * * * * D I S C L A I M E R * * * * * * * * * * * * *
Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer en 
binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is 
door een geldig ondertekend document.
The views expressed in this message and any annex are purely those of the 
writer and may not be regarded as stating an official position of INBO, as long 
as the message is not confirmed by a duly signed document.

______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to