Title of page with multiple plots

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Title of page with multiple plots

John Sorkin
I want to place four plots on a page, and I would like to have all four
plots share a common title. I have tried the following code, but the
title is centered over the fourth graph and not centered across all four
plots. Does anyone have any suggestions?

R 2.1.1
windows xp

oldpar<-par(mfcol =c(1,4),ask=TRUE)


plot(p,varp)
plot(p,SEp)
plot(p,CVp)
plot(p,ppval)

title(paste("P and 95%CI for a sample size of",n,"subjects."))

Thanks,
John

John Sorkin M.D., Ph.D.
Chief, Biostatistics and Informatics
Baltimore VA Medical Center GRECC and
University of Maryland School of Medicine Claude Pepper OAIC

University of Maryland School of Medicine
Division of Gerontology
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524

410-605-7119
[hidden email]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: Title of page with multiple plots

jholtman
try this:

> par(mfcol=c(2,2))
> plot(0)
> plot(0)
> plot(0)
> plot(0)
> mtext('main title', outer=TRUE, line=-1)
>



On 5/11/06, John Sorkin <[hidden email]> wrote:

>
> I want to place four plots on a page, and I would like to have all four
> plots share a common title. I have tried the following code, but the
> title is centered over the fourth graph and not centered across all four
> plots. Does anyone have any suggestions?
>
> R 2.1.1
> windows xp
>
> oldpar<-par(mfcol =c(1,4),ask=TRUE)
>
>
> plot(p,varp)
> plot(p,SEp)
> plot(p,CVp)
> plot(p,ppval)
>
> title(paste("P and 95%CI for a sample size of",n,"subjects."))
>
> Thanks,
> John
>
> John Sorkin M.D., Ph.D.
> Chief, Biostatistics and Informatics
> Baltimore VA Medical Center GRECC and
> University of Maryland School of Medicine Claude Pepper OAIC
>
> University of Maryland School of Medicine
> Division of Gerontology
> Baltimore VA Medical Center
> 10 North Greene Street
> GRECC (BT/18/GR)
> Baltimore, MD 21201-1524
>
> 410-605-7119
> [hidden email]
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
>



--
Jim Holtman
Cincinnati, OH
+1 513 646 9390 (Cell)
+1 513 247 0281 (Home)

What is the problem you are trying to solve?

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: Title of page with multiple plots

Andrew Robinson-6
In reply to this post by John Sorkin
John,

try adding the argument outer=T to the title() function

title(paste("P and 95%CI for a sample size of",n,"subjects."), outer=T)

Cheers

Andrew

On Thu, May 11, 2006 at 08:00:34PM -0400, John Sorkin wrote:

> I want to place four plots on a page, and I would like to have all four
> plots share a common title. I have tried the following code, but the
> title is centered over the fourth graph and not centered across all four
> plots. Does anyone have any suggestions?
>
> R 2.1.1
> windows xp
>
> oldpar<-par(mfcol =c(1,4),ask=TRUE)
>
>
> plot(p,varp)
> plot(p,SEp)
> plot(p,CVp)
> plot(p,ppval)
>
> title(paste("P and 95%CI for a sample size of",n,"subjects."))
>
> Thanks,
> John
>
> John Sorkin M.D., Ph.D.
> Chief, Biostatistics and Informatics
> Baltimore VA Medical Center GRECC and
> University of Maryland School of Medicine Claude Pepper OAIC
>
> University of Maryland School of Medicine
> Division of Gerontology
> Baltimore VA Medical Center
> 10 North Greene Street
> GRECC (BT/18/GR)
> Baltimore, MD 21201-1524
>
> 410-605-7119
> [hidden email]
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

--
Andrew Robinson  
Department of Mathematics and Statistics            Tel: +61-3-8344-9763
University of Melbourne, VIC 3010 Australia         Fax: +61-3-8344-4599
Email: [hidden email]         http://www.ms.unimelb.edu.au

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: Title of page with multiple plots

Martin Maechler
In reply to this post by jholtman
>>>>> "jim" == jim holtman <[hidden email]>
>>>>>     on Thu, 11 May 2006 20:31:14 -0400 writes:

    jim> try this:
    >> par(mfcol=c(2,2))
    >> plot(0)
    >> plot(0)
    >> plot(0)
    >> plot(0)
    >> mtext('main title', outer=TRUE, line=-1)

Yes.  Because the 'Subject' of this thread is such common task
(for some), I had created the function mult.fig() about ten
years ago (in S-plus times).  That is now part of the 'sfsmisc'
package.

After
    > install.packages("sfsmisc")
you can use
    > sfsmisc::mult.fig(4, main = "main title")

and then do your for plots afterwards.
mult.fig() has the other advantage of using slightly smaller
margins for the single plots, by default, so you get more "real
estate" for plotting.


Martin Maechler, ETH Zurich




    jim> On 5/11/06, John Sorkin <[hidden email]> wrote:
    >>
    >> I want to place four plots on a page, and I would like to have all four
    >> plots share a common title. I have tried the following code, but the
    >> title is centered over the fourth graph and not centered across all four
    >> plots. Does anyone have any suggestions?
    >>
    >> R 2.1.1
    >> windows xp
    >>
    >> oldpar<-par(mfcol =c(1,4),ask=TRUE)
    >>
    >>
    >> plot(p,varp)
    >> plot(p,SEp)
    >> plot(p,CVp)
    >> plot(p,ppval)
    >>
    >> title(paste("P and 95%CI for a sample size of",n,"subjects."))
    >>
    >> Thanks,
    >> John
    >>
    >> John Sorkin M.D., Ph.D.
    >> Chief, Biostatistics and Informatics
    >> Baltimore VA Medical Center GRECC and
    >> University of Maryland School of Medicine Claude Pepper OAIC
    >>
    >> University of Maryland School of Medicine
    >> Division of Gerontology
    >> Baltimore VA Medical Center
    >> 10 North Greene Street
    >> GRECC (BT/18/GR)
    >> Baltimore, MD 21201-1524
    >>
    >> 410-605-7119
    >> [hidden email]
    >>
    >> ______________________________________________
    >> [hidden email] mailing list
    >> https://stat.ethz.ch/mailman/listinfo/r-help
    >> PLEASE do read the posting guide!
    >> http://www.R-project.org/posting-guide.html
    >>



    jim> --
    jim> Jim Holtman
    jim> Cincinnati, OH
    jim> +1 513 646 9390 (Cell)
    jim> +1 513 247 0281 (Home)

    jim> What is the problem you are trying to solve?

    jim> [[alternative HTML version deleted]]

    jim> ______________________________________________
    jim> [hidden email] mailing list
    jim> https://stat.ethz.ch/mailman/listinfo/r-help
    jim> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: Title of page with multiple plots

Earl F. Glynn
In reply to this post by John Sorkin
"John Sorkin" <[hidden email]> wrote in message
news:[hidden email]...
> I want to place four plots on a page, and I would like to have all four
> plots share a common title. I have tried the following code, but the
> title is centered over the fourth graph and not centered across all four
> plots. Does anyone have any suggestions?

You may want to adjust the "North" parameters for the outer margin area
(oma) and the regular margin (mar):

# oma and mar: c(South,West,North,East)
oldpar <- par(mfcol =c(1,4), oma=c(0,0,2,0), mar=c(5.1,4.1,0,2.1))

plot(1)
plot(2)
plot(3)
plot(4)

title("Common title", outer=TRUE)

par(oldpar)


efg
Earl F. Glynn
Scientific Programmer
Bioinformatics
Stowers Institute for Medical Research

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html