[R] histogram in the background?
John Kane
jrkrideau at yahoo.ca
Wed Sep 6 15:17:28 CEST 2006
--- 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?
> >
> >
>
http://addictedtor.free.fr/graphiques/RGraphGallery.php?graph=78
> >
> > JeeBee
Can 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()
More information about the R-help
mailing list