I've looked long and hard for this, but maybe I am missing something... There is a nice module that displays histograms reflected in the y axis, i.e. http://addictedtor.free.fr/graphiques/RGraphGallery.php?graph=136 but is it possible to reflect in the x-axis, so to have two datasets, one pointing up and one down rather than left and right? I haven't been able to find a way to plot this way using the guide, or elsewhere. Thanks... -- View this message in context: http://www.nabble.com/Reflect-Back-to-Back-Histograms-in-x-axis--tp23923800p23923800.html Sent from the R help mailing list archive at Nabble.com.
On 08-Jun-09 13:11:03, sedm1000 wrote:> I've looked long and hard for this, but maybe I am missing something... > > There is a nice module that displays histograms reflected in the > y axis, i.e. > http://addictedtor.free.fr/graphiques/RGraphGallery.php?graph=136 > > but is it possible to reflect in the x-axis, so to have two datasets, > one pointing up and one down rather than left and right? I haven't > been able to find a way to plot this way using the guide, or elsewhere. > > Thanks... > --[Sorry, there was a superfluous line in the code I posted previously. Commented out below to show where it was] Try along the lines of: set.seed(54321) X1 <- rnorm(500) X2 <- rnorm(500) ##H1 <- hist(X1,breaks=0.5*((-8):8),ylim=c(-100,100)) H1 <- hist(X1,breaks=0.5*((-8):8),ylim=c(-100,100),col="red") H2 <- hist(X2,breaks=0.5*((-8):8),plot=FALSE) H3<-H2 ; H3$counts <- -H3$counts plot(H3,add=TRUE,col="blue") NB: The choice of breaks and ylim was made after a preliminary inspection of hist(X1) and hist(X2). Ted. -------------------------------------------------------------------- E-Mail: (Ted Harding) <Ted.Harding at manchester.ac.uk> Fax-to-email: +44 (0)870 094 0861 Date: 08-Jun-09 Time: 15:50:48 ------------------------------ XFMail ------------------------------ -------------------------------------------------------------------- E-Mail: (Ted Harding) <Ted.Harding at manchester.ac.uk> Fax-to-email: +44 (0)870 094 0861 Date: 08-Jun-09 Time: 15:54:40 ------------------------------ XFMail ------------------------------
Thanks very much for that, most useful... Ted.Harding-2 wrote:> > On 08-Jun-09 13:11:03, sedm1000 wrote: >> I've looked long and hard for this, but maybe I am missing something... >> >> There is a nice module that displays histograms reflected in the >> y axis, i.e. >> http://addictedtor.free.fr/graphiques/RGraphGallery.php?graph=136 >> >> but is it possible to reflect in the x-axis, so to have two datasets, >> one pointing up and one down rather than left and right? I haven't >> been able to find a way to plot this way using the guide, or elsewhere. >> >> Thanks... >> -- > > Try along the lines of: > > set.seed(54321) > X1 <- rnorm(500) > X2 <- rnorm(500) > H1 <- hist(X1,breaks=0.5*((-8):8),ylim=c(-100,100)) > H1 <- hist(X1,breaks=0.5*((-8):8),ylim=c(-100,100),col="red") > H2 <- hist(X2,breaks=0.5*((-8):8),plot=FALSE) > H3<-H2 ; H3$counts <- -H3$counts > plot(H3,add=TRUE,col="blue") > > NB: The choice of breaks and ylim was made after a preliminary > inspection of hist(X1) and hist(X2). > > Ted. > > -------------------------------------------------------------------- > E-Mail: (Ted Harding) <Ted.Harding at manchester.ac.uk> > Fax-to-email: +44 (0)870 094 0861 > Date: 08-Jun-09 Time: 15:50:48 > ------------------------------ XFMail ------------------------------ > > ______________________________________________ > 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. > >-- View this message in context: http://www.nabble.com/Reflect-Back-to-Back-Histograms-in-x-axis--tp23923800p23930213.html Sent from the R help mailing list archive at Nabble.com.