"juli g. pausas" <[EMAIL PROTECTED]> writes: > Dear colleges, > I'm trying to combine a barplot and a plot in a single figure as follows: > > data <- 1:6 > t <- barplot(data, axes=F) > par(new= T) > plot(t, data, type="b") > > However, as you can see in the example, the dots of the second plot do > not fall in the midpoint of the bars in the first. Any trick for > setting the 2 plots at the same scale? > I have unsuccessfully tried: > plot(t, data, type="b", xlim=c(0,7)) > plot(t, data, type="b", xlim=c(min(t),max(t))) > > (R 1.8.1, for Windows)
The canonical trick for getting two plots on the same scale is to set xlim (and ylim) on *both*. On barplots, this gets a bit tricky since you have to leave room for the column width (the actual calculation can be read inside barplot.default). However, I'd try for something like t <- barplot(data,names=1:6,ylim=range(c(0,data*1.01))) points(t, data, type="b") -- O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 ______________________________________________ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help