[R] add histograms or distributions on regression line

Greg Snow Greg.Snow at intermountainmail.org
Mon Nov 5 19:38:48 CET 2007


Here are a couple of options that may get you started:

library(TeachingDemos)

plot(1:10, 1:10, type='n')
abline(0,1)

rhist <- function(x){
	tmp <- hist(x, plot=FALSE)
	barplot(tmp$counts, horiz=TRUE, axes=FALSE, space=0)
}

subplot( rhist(rnorm(100)), 2,2, hadj=0 )
subplot( rhist(rnorm(100)), 5,5, hadj=0 )
subplot( rhist(rnorm(100)), 7,7, hadj=0 )

y <- seq(-3,3, len=100)
x <- dnorm(y)
x <- x/(max(x))
ms.norm <- cbind(x,y)

plot(1:10,1:10, type='n')
abline(0,1)

my.symbols( 1:10, 1:10, ms.norm, inches=0.3 )

plot(1:10,1:10, type='n')
abline(0,1)

my.symbols( 1:10, 1:10, ms.norm, inches=seq(.2,.5,len=10) )



Hope this helps,

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.snow at intermountainmail.org
(801) 408-8111
 
 

> -----Original Message-----
> From: r-help-bounces at r-project.org 
> [mailto:r-help-bounces at r-project.org] On Behalf Of Chang jun xiang
> Sent: Friday, November 02, 2007 8:09 AM
> To: r-help at r-project.org
> Subject: [R] add histograms or distributions on regression line
> 
> hello, does anyone know how to add histograms or 
> distributions on regression like just like quantiles 
> regression in RGraphGallery below, a very delicate codes. Thanks alot.
> 
> http://addictedtor.free.fr/graphiques/RGraphGallery.php?graph=109
> 
> ______________________________________________
> 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.
> 



More information about the R-help mailing list