Chang jun xiang
2007-Nov-02 14:09 UTC
[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
If you go to the source code area of the page and click on one of the icons to get the source code for that graph. The code looks a bit complex for me to figure out quickly , but it may give you a start on how to approach it. --- Chang jun xiang <d96627003 at ntu.edu.tw> wrote:> 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. >
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.
>