[R] R package to automatically produce combination plot?

Paul Murrell p.murrell at auckland.ac.nz
Tue Mar 17 20:51:27 CET 2009


Hi


Jason Rupert wrote:
> I guess no reply means there is not an existing package to produce
> the plot?
> 
> I will post the results of my script to hopefully help others who are
> trying to formulate the same plot.
> 
> Thanks again.


I don't know of an existing function that does that particular
arrangement of plots, but here's a start ...


breaks <- seq(-3.5, 3.5, by=.5)
yrange <- range(breaks)

histdata <- hist(y, breaks=breaks, plot=FALSE)
densitydata <- density(y)

par(oma=rep(3, 4), mar=rep(0, 4))

layout(matrix(1:3, ncol=3), widths=c(.2, .1, 1), respect=TRUE)

barplot(histdata$density, horiz=TRUE, space=0,
        xlim=c(0, max(histdata$density)*1.1), axes=FALSE)
par(new=TRUE)
plot(densitydata$y, densitydata$x,
     xlim=c(0, max(histdata$density)*1.1), ylim=yrange,
     type="l", ann=FALSE, axes=FALSE)
axis(2)
box()
boxplot(y, ylim=yrange, axes=FALSE)
box()
qqnorm(y, axes=FALSE, ylim=yrange, xlim=yrange, main="")
abline(0, 1)
axis(1)
box()


... the important bits are the call to layout() to get the plots at
different sizes and the numerous efforts made to make sure that the
coordinate systems of the various plots are coherent.

Paul


> --- On Mon, 3/16/09, Jason Rupert <jasonkrupert at yahoo.com> wrote:
> 
>> From: Jason Rupert <jasonkrupert at yahoo.com> Subject: [R] R package
>> to automatically produce combination plot? To: R-help at r-project.org
>>  Date: Monday, March 16, 2009, 8:14 PM By any chance is there an R
>> package that automatically produces the plot shown at the following
>> link: http://n2.nabble.com/Can-R-produce-this-plot--td2489288.html
>> 
>> That is an R package to produce on plot that has the following: (a)
>> a vertically oriented histogram, (b) associated barplot, and (c)
>> quantile-quantile plot (Q-Q Plot).
>> 
>> This is based on a class lecture from University of Pennsylvania: 
>> stat.wharton.upenn.edu/~mcjon/stat-431/lecture-02.pdf
>> 
>> I am pretty confident I can put one together, but just wanted to
>> check that there does not already exist an R package to output such
>> a plot.
>> 
>> Thanks again.
>> 
>> ______________________________________________ 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.

-- 
Dr Paul Murrell
Department of Statistics
The University of Auckland
Private Bag 92019
Auckland
New Zealand
64 9 3737599 x85392
paul at stat.auckland.ac.nz
http://www.stat.auckland.ac.nz/~paul/




More information about the R-help mailing list