Does anyone have a simple explanation and example on how to add histograms or barcharts to an other graph like in the example at the R-graph gallery: http://addictedtor.free.fr/graphiques/RGraphGallery.php?graph=109 looking at the code I'not undertand very well how to add graphs in arbitrary/clever position with an adequate scale. If somebody have a simplier example with explanations it will be highly appreciate. Best Daniele ------------------------------------------------------ Scegli infostrada: ADSL gratis per tutta l?estate e telefoni senza canone Telecom
multiple graphs
3 messages · Daniele Amberti, PIKAL Petr, Greg Snow
Hi this particular graph is a combination of several approaches see layout # how to split plot window (or ?split) par(new=TRUE) # how to plot several times to the same window without erasing previous plot and of course sophisticated use of all other stuff which is available in R. See also par(fig=...) plot(1:10) par(fig=c(0.1,.5,0.1,.5), new=T) boxplot(rnorm(10)) Petr r-help-bounces at stat.math.ethz.ch napsal dne 26.07.2007 09:26:16:
Does anyone have a simple explanation and example on how to add
histograms or
barcharts to an other graph like in the example at the R-graph gallery: http://addictedtor.free.fr/graphiques/RGraphGallery.php?graph=109 looking at the code I'not undertand very well how to add graphs in arbitrary/clever position with an adequate scale. If somebody have a simplier example with explanations it will be highly
appreciate.
Best Daniele ------------------------------------------------------ Scegli infostrada: ADSL gratis per tutta l?estate e telefoni senza
canone Telecom
______________________________________________ R-help at stat.math.ethz.ch 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.
One of the nice things about the R Graph Gallery is that if you click on
the R logo underneath the graph (may need to scroll down a bit) it will
show you the code used to create that particular graph.
You may also want to look at the subplot function in the TeachingDemos
package for another way to add histograms to a plot:
Here is one possible example of this:
x <- rep(1:10, each=25)
y <- rexp(250, 1/x)
library(TeachingDemos)
tmp1 <- hist(y, plot=FALSE)
r <- range(tmp1$breaks)
w <- diff(tmp1$breaks)
plot(x,y, type='n', xlim=c(0.5,10.5), ylim=r)
for(i in 1:10){
tmp2 <- hist( y[x==i], breaks=tmp1$breaks, plot=FALSE )
subplot( barplot(tmp2$counts, ylim=r, width=w,
horiz=TRUE, space=0, xaxt='n', yaxs='i'),
c(i-0.45, i+.45), r
)
}
points(x,y) # just to compare
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 stat.math.ethz.ch > [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Daniele Amberti > Sent: Thursday, July 26, 2007 1:26 AM > To: r-help > Subject: [R] multiple graphs > > Does anyone have a simple explanation and example on how to > add histograms or barcharts to an other graph like in the > example at the R-graph gallery: > > http://addictedtor.free.fr/graphiques/RGraphGallery.php?graph=109 > > looking at the code I'not undertand very well how to add > graphs in arbitrary/clever position with an adequate scale. > > If somebody have a simplier example with explanations it will > be highly appreciate. > > Best > Daniele > > > ------------------------------------------------------ > Scegli infostrada: ADSL gratis per tutta l'estate e telefoni > senza canone Telecom > > ______________________________________________ > R-help at stat.math.ethz.ch 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. >