Skip to content
Prev 24233 / 398503 Next

barplot + plot

exact
starting
Juli,

The difference is in the way that barplot() and plot() draw the style of
axes by default.

In barplot(), which you call first, it sets par(yaxs = "i") explicitly
in the code.

Unless you change it, plot() uses the default parameter value of
par(yaxs = "r"), which draws a different style of axis.

If you add:

par(yaxs = "i") before your plot(...) line, you will get a consistent 0
starting point.

See ?par and scroll to par(xaxs), which describes the style of axes
available for both x and y.

Thus, your example code should look like:

barplot(1:5, ylim=c(0, 9))
par(new= T)
par(yaxs = "i")
plot(1:5, 9:5, type="b", axes=FALSE, ylim=c(0,6))
axis(4)
box()

I presume that you explicitly want the y axis ranges to be different.
If not, be sure to set ylim to the same values.

HTH.

Marc Schwartz



-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._