I intend to draw a plot of y against x. In the background of this graph I wish to creat a histogram of the horizontal variable x. Does any expert know how to produce such a plot? [[alternative HTML version deleted]]
How about this? addictedtor.free.fr/graphiques/RGraphGallery.php?graph=78 JeeBee On Wed, 06 Sep 2006 18:19:28 +0800, gallon li wrote:> I intend to draw a plot of y against x. In the background of this graph I > wish to creat a histogram of the horizontal variable x. Does any expert > know how to produce such a plot? > > [[alternative HTML version deleted]] > > ______________________________________________ R-help at stat.math.ethz.ch > mailing list stat.ethz.ch/mailman/listinfo/r-help PLEASE do read > the posting guide R-project.org/posting-guide.html and provide > commented, minimal, self-contained, reproducible code.
gallon li wrote: I have found this one before. However, my intension is slightly differing from this plot: I wish to plot the histogram in the backgroun instead of in the margin. Thanks anyway! On Wed, 06 Sep 2006 12:29:51 +0200, JeeBee wrote:> > How about this? > > addictedtor.free.fr/graphiques/RGraphGallery.php?graph=78 > > JeeBee >
--- JeeBee <JeeBee at troefpunt.nl> wrote:> gallon li wrote: > > I have found this one before. However, my intension > is slightly differing > from this plot: I wish to plot the histogram in the > backgroun instead of > in the margin. Thanks anyway! > > On Wed, 06 Sep 2006 12:29:51 +0200, JeeBee wrote: > > > > > How about this? > > > > >addictedtor.free.fr/graphiques/RGraphGallery.php?graph=78> > > > JeeBeeCan you not just plot the histogram and then the main plot? Something like this, although it is a barplot rather than a histogram. Hours <- c(0,1,2,3,4,5) Nam <- c( "alf", "bet", "cet", "det", NA , fet) En <- c(5, 7, 8, 9, NA, 9) L1 <- c(10, 9, 7, 5, 3 ,6) L2 <- c(7, 4, 3, 2, 5, 7) MyLabels <- seq(200, 500, length=13) mp <-barplot(En) # adjust margins to accommodate titles and labels especially the 4 axis label. par(mar=c(5,5,5,5)) barplot(En, ylim=c(0, 12),axes =FALSE, ann=FALSE, xlab="Hours", ylab="Volume", col.lab="blue") points (mp,L1, type="p", pch=19, col = "red") points (mp,L2, type = "l", col="blue") axis ( 2, 0:12, las=1, font=2) axis (3, at=1:6, tick =F, labels =c( "alf", "bet", "cet", "det", NA , "fet")) axis (4, at = 0:12, labels = MyLabels, font=2) mtext("Number of Units Detected", 4, line=3,col="blue") title ( main="A combined line and bar chart \n with different x-axis labels", line=3, font=3, col.main="blue") box()
> I intend to draw a plot of y against x. In the background of this graph I > wish to creat a histogram of the horizontal variable x. Does any expert know > how to produce such a plot?When constructing such a plot, you need to be careful that you don't end up constructing a pretty picture instead of a statistical graphic. In this case you need to ask yourself, what would the y-axis represent? What scale would it have? Hadley