[R] barplot & plot together
Martin Maechler
maechler at stat.math.ethz.ch
Thu Dec 18 11:21:13 CET 2003
>>>>> "juli" == juli g pausas <juli at ceam.es>
>>>>> on Thu, 18 Dec 2003 10:54:08 +0100 writes:
juli> Dear colleges,
juli> I'm trying to combine a barplot and a plot in a single figure as follows:
juli> data <- 1:6
juli> t <- barplot(data, axes=F)
juli> par(new= T)
juli> plot(t, data, type="b")
juli> However, as you can see in the example, the dots of
juli> the second plot do not fall in the midpoint of the
juli> bars in the first. Any trick for setting the 2 plots
juli> at the same scale?
yes, use
bd <- barplot(data)
points(bd, data, type = "b")
instead.
A general recommendation:
Try to *not* use par(new = TRUE) if you can.
Martin
More information about the R-help
mailing list