How can I add an overall plot title to these four plots?
I would like to have something that says, "Distribution Comparisons":
par(mfrow = c(2, 2))
# Plot 1
plot(rnorm(10),type="l",col="red")
title(main = list(paste("Normal"),
????????????????????????? col="black", cex = 1.0))
# Plot 2
plot(rpois(10, 4),type="l",col="blue")
title(main = list(paste("Poison"),
????????????????????????? col="black", cex = 1.0))
# Plot 3
plot(rnbinom(10, mu = 4, size = 100),type="l",col="green")
title(main = list(paste("Binomial"),
????????????????????????? col="black", cex = 1.0))
# Plot 4
plot(runif(10),type="l",col="black")
title(main = list(paste("Uniform"),
????????????????????????? col="black", cex = 1.0))
Thanks again for any feedback and insights.
How to add a top level title to multiple plots
7 messages · Jason Rupert, Phil Spector, David Winsemius +1 more
Jason -
I've found the mult.fig.p function in the cwhmisc package
to be very handy for this sort of thing.
- Phil Spector
Statistical Computing Facility
Department of Statistics
UC Berkeley
spector at stat.berkeley.edu
On Fri, 20 Nov 2009, Jason Rupert wrote:
How can I add an overall plot title to these four plots?
I would like to have something that says, "Distribution Comparisons":
par(mfrow = c(2, 2))
# Plot 1
plot(rnorm(10),type="l",col="red")
title(main = list(paste("Normal"),
????????????????????????? col="black", cex = 1.0))
# Plot 2
plot(rpois(10, 4),type="l",col="blue")
title(main = list(paste("Poison"),
????????????????????????? col="black", cex = 1.0))
# Plot 3
plot(rnbinom(10, mu = 4, size = 100),type="l",col="green")
title(main = list(paste("Binomial"),
????????????????????????? col="black", cex = 1.0))
# Plot 4
plot(runif(10),type="l",col="black")
title(main = list(paste("Uniform"),
????????????????????????? col="black", cex = 1.0))
Thanks again for any feedback and insights.
______________________________________________ R-help at r-project.org 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.
Jason Rupert wrote:
How can I add an overall plot title to these four plots? I would like to have something that says, "Distribution Comparisons":
title("Distribution Comparisons", outer = TRUE)
But you may have to make room for it with par(oma=...).
-Peter Ehlers
par(mfrow = c(2, 2))
# Plot 1
plot(rnorm(10),type="l",col="red")
title(main = list(paste("Normal"),
col="black", cex = 1.0))
# Plot 2
plot(rpois(10, 4),type="l",col="blue")
title(main = list(paste("Poison"),
col="black", cex = 1.0))
# Plot 3
plot(rnbinom(10, mu = 4, size = 100),type="l",col="green")
title(main = list(paste("Binomial"),
col="black", cex = 1.0))
# Plot 4
plot(runif(10),type="l",col="black")
title(main = list(paste("Uniform"),
col="black", cex = 1.0))
Thanks again for any feedback and insights.
______________________________________________ R-help at r-project.org 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.
Cool.
I ended up with the following:
par(mfrow = c(2, 2))
# Plot 1
plot(rnorm(10),type="l",col="red")
title(main = list(paste("Normal"),
col="black", cex = 1.0))
# Plot 2
plot(rpois(10, 4),type="l",col="blue")
title(main = list(paste("Poison"),
col="black", cex = 1.0))
# Plot 3
plot(rnbinom(10, mu = 4, size = 100),type="l",col="green")
title(main = list(paste("Binomial"),
col="black", cex = 1.0))
# Plot 4
plot(runif(10),type="l",col="black")
title(main = list(paste("Uniform"),
col="black", cex = 1.0))
title("Distribution Comparisons", outer = TRUE)
# c(bottom, left, top, right)
par(oma=c(2,2,3,2))
Thanks again.
----- Original Message ----
From: Peter Ehlers <ehlers at ucalgary.ca>
To: Jason Rupert <jasonkrupert at yahoo.com>
Cc: R-help at r-project.org
Sent: Fri, November 20, 2009 5:23:33 PM
Subject: Re: [R] How to add a top level title to multiple plots
Jason Rupert wrote:
How can I add an overall plot title to these four plots? I would like to have something that says, "Distribution Comparisons":
title("Distribution Comparisons", outer = TRUE)
But you may have to make room for it with par(oma=...).
-Peter Ehlers
par(mfrow = c(2, 2))
# Plot 1
plot(rnorm(10),type="l",col="red")
title(main = list(paste("Normal"),
col="black", cex = 1.0))
# Plot 2
plot(rpois(10, 4),type="l",col="blue")
title(main = list(paste("Poison"),
col="black", cex = 1.0))
# Plot 3
plot(rnbinom(10, mu = 4, size = 100),type="l",col="green")
title(main = list(paste("Binomial"),
col="black", cex = 1.0))
# Plot 4
plot(runif(10),type="l",col="black")
title(main = list(paste("Uniform"),
col="black", cex = 1.0))
Thanks again for any feedback and insights.
______________________________________________ R-help at r-project.org 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.
2 days later
In the example below, is there any way to get the top title, i.e. "Distribution Comparisons", in a bit from the top margin??
Thanks agian
?
----- Original Message ----
From: Jason Rupert <jasonkrupert at yahoo.com>
To: Peter Ehlers <ehlers at ucalgary.ca>
Cc: R Project Help <R-help at r-project.org>; Me <jasonkrupert at yahoo.com>
Sent: Sat, November 21, 2009 12:31:04 AM
Subject: Re: [R] How to add a top level title to multiple plots
Cool.
I ended up with the following:
par(mfrow = c(2, 2))
# Plot 1
plot(rnorm(10),type="l",col="red")
title(main = list(paste("Normal"),
? ? ? col="black", cex = 1.0))
# Plot 2
plot(rpois(10, 4),type="l",col="blue")
title(main = list(paste("Poison"),
? ? ? col="black", cex = 1.0))
# Plot 3
plot(rnbinom(10, mu = 4, size = 100),type="l",col="green")
title(main = list(paste("Binomial"),
? ? ? col="black", cex = 1.0))
# Plot 4
plot(runif(10),type="l",col="black")
title(main = list(paste("Uniform"),
? ? ? col="black", cex = 1.0))
title("Distribution Comparisons", outer = TRUE)
# c(bottom, left, top, right)
par(oma=c(2,2,3,2))
Thanks again.
----- Original Message ----
From: Peter Ehlers <ehlers at ucalgary.ca>
To: Jason Rupert <jasonkrupert at yahoo.com>
Cc: R-help at r-project.org
Sent: Fri, November 20, 2009 5:23:33 PM
Subject: Re: [R] How to add a top level title to multiple plots
Jason Rupert wrote:
How can I add an overall plot title to these four plots? I would like to have something that says, "Distribution Comparisons":
title("Distribution Comparisons", outer = TRUE)
But you may have to make room for it with par(oma=...).
-Peter Ehlers
par(mfrow = c(2, 2))
# Plot 1
plot(rnorm(10),type="l",col="red")
title(main = list(paste("Normal"),
? ? ? ? ? ? ? ? ? ? ? ? ? col="black", cex = 1.0))
# Plot 2
plot(rpois(10, 4),type="l",col="blue")
title(main = list(paste("Poison"),
? ? ? ? ? ? ? ? ? ? ? ? ? col="black", cex = 1.0))
# Plot 3
plot(rnbinom(10, mu = 4, size = 100),type="l",col="green")
title(main = list(paste("Binomial"),
? ? ? ? ? ? ? ? ? ? ? ? ? col="black", cex = 1.0))
# Plot 4
plot(runif(10),type="l",col="black")
title(main = list(paste("Uniform"),
? ? ? ? ? ? ? ? ? ? ? ? ? col="black", cex = 1.0))
Thanks again for any feedback and insights.
______________________________________________ R-help at r-project.org 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.
On Nov 23, 2009, at 8:58 AM, Jason Rupert wrote:
In the example below, is there any way to get the top title, i.e. "Distribution Comparisons", in a bit from the top margin?
You could use instead:
title("\nDistribution Comparisons", outer = TRUE)
And please correct the spelling of Poisson.
David
> Thanks agian
>
>
>
>
>
> ----- Original Message ----
> From: Jason Rupert <jasonkrupert at yahoo.com>
> To: Peter Ehlers <ehlers at ucalgary.ca>
> Cc: R Project Help <R-help at r-project.org>; Me <jasonkrupert at yahoo.com>
> Sent: Sat, November 21, 2009 12:31:04 AM
> Subject: Re: [R] How to add a top level title to multiple plots
>
> Cool.
>
> I ended up with the following:
>
>
>
> par(mfrow = c(2, 2))
> # Plot 1
> plot(rnorm(10),type="l",col="red")
> title(main = list(paste("Normal"),
> col="black", cex = 1.0))
>
>
> # Plot 2
> plot(rpois(10, 4),type="l",col="blue")
> title(main = list(paste("Poison"),
> col="black", cex = 1.0))
>
>
> # Plot 3
> plot(rnbinom(10, mu = 4, size = 100),type="l",col="green")
> title(main = list(paste("Binomial"),
> col="black", cex = 1.0))
>
> # Plot 4
> plot(runif(10),type="l",col="black")
> title(main = list(paste("Uniform"),
> col="black", cex = 1.0))
>
>
> title("Distribution Comparisons", outer = TRUE)
>
> # c(bottom, left, top, right)
> par(oma=c(2,2,3,2))
>
>
> Thanks again.
>
>
>
>
>
> ----- Original Message ----
> From: Peter Ehlers <ehlers at ucalgary.ca>
> To: Jason Rupert <jasonkrupert at yahoo.com>
> Cc: R-help at r-project.org
> Sent: Fri, November 20, 2009 5:23:33 PM
> Subject: Re: [R] How to add a top level title to multiple plots
>
>
> Jason Rupert wrote:
>> How can I add an overall plot title to these four plots?
>> I would like to have something that says, "Distribution Comparisons":
>>
> title("Distribution Comparisons", outer = TRUE)
>
> But you may have to make room for it with par(oma=...).
>
> -Peter Ehlers
>
>>
>> par(mfrow = c(2, 2))
>> # Plot 1
>> plot(rnorm(10),type="l",col="red")
>> title(main = list(paste("Normal"),
>> col="black", cex = 1.0))
>>
>>
>> # Plot 2
>> plot(rpois(10, 4),type="l",col="blue")
>> title(main = list(paste("Poison"),
>> col="black", cex = 1.0))
>>
>>
>> # Plot 3
>> plot(rnbinom(10, mu = 4, size = 100),type="l",col="green")
>> title(main = list(paste("Binomial"),
>> col="black", cex = 1.0))
>>
>> # Plot 4
>> plot(runif(10),type="l",col="black")
>> title(main = list(paste("Uniform"),
>> col="black", cex = 1.0))
>>
>>
>> Thanks again for any feedback and insights.
>>
>>
>>
>> ______________________________________________
>> R-help at r-project.org 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.
>>
>>
>
>
>
>
> ______________________________________________
> R-help at r-project.org 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.
David Winsemius, MD
Heritage Laboratories
West Hartford, CT
Jason Rupert wrote:
In the example below, is there any way to get the top title, i.e. "Distribution Comparisons", in a bit from the top margin? Thanks agian
Your par(oma=...) needs to come _before_ plotting; make it the first statement. In addition, title() takes a line= argument; try line=0.5 or even line=-1.0. -Peter Ehlers
----- Original Message ----
From: Jason Rupert <jasonkrupert at yahoo.com>
To: Peter Ehlers <ehlers at ucalgary.ca>
Cc: R Project Help <R-help at r-project.org>; Me <jasonkrupert at yahoo.com>
Sent: Sat, November 21, 2009 12:31:04 AM
Subject: Re: [R] How to add a top level title to multiple plots
Cool.
I ended up with the following:
par(mfrow = c(2, 2))
# Plot 1
plot(rnorm(10),type="l",col="red")
title(main = list(paste("Normal"),
col="black", cex = 1.0))
# Plot 2
plot(rpois(10, 4),type="l",col="blue")
title(main = list(paste("Poison"),
col="black", cex = 1.0))
# Plot 3
plot(rnbinom(10, mu = 4, size = 100),type="l",col="green")
title(main = list(paste("Binomial"),
col="black", cex = 1.0))
# Plot 4
plot(runif(10),type="l",col="black")
title(main = list(paste("Uniform"),
col="black", cex = 1.0))
title("Distribution Comparisons", outer = TRUE)
# c(bottom, left, top, right)
par(oma=c(2,2,3,2))
Thanks again.
----- Original Message ----
From: Peter Ehlers <ehlers at ucalgary.ca>
To: Jason Rupert <jasonkrupert at yahoo.com>
Cc: R-help at r-project.org
Sent: Fri, November 20, 2009 5:23:33 PM
Subject: Re: [R] How to add a top level title to multiple plots
Jason Rupert wrote:
How can I add an overall plot title to these four plots? I would like to have something that says, "Distribution Comparisons":
title("Distribution Comparisons", outer = TRUE)
But you may have to make room for it with par(oma=...).
-Peter Ehlers
par(mfrow = c(2, 2))
# Plot 1
plot(rnorm(10),type="l",col="red")
title(main = list(paste("Normal"),
col="black", cex = 1.0))
# Plot 2
plot(rpois(10, 4),type="l",col="blue")
title(main = list(paste("Poison"),
col="black", cex = 1.0))
# Plot 3
plot(rnbinom(10, mu = 4, size = 100),type="l",col="green")
title(main = list(paste("Binomial"),
col="black", cex = 1.0))
# Plot 4
plot(runif(10),type="l",col="black")
title(main = list(paste("Uniform"),
col="black", cex = 1.0))
Thanks again for any feedback and insights.
______________________________________________ R-help at r-project.org 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.