On Fri, Feb 13, 2009 at 1:51 PM, Marc Schwartz <marc_schwa...@comcast.net> wrote: > on 02/13/2009 01:25 PM Paul Johnson wrote: >> Hello, everybody. >> >> A student asked me a howto question I can't answer. We want the >> length of the drawn axes to fill the full width and height of the >> plot, like so:
> Paul, > > I am guessing that you want: > > x <- rnorm(100) > z <- gl(2,50) > y <- rnorm(100, mean= 1.8*as.numeric(z)) > > plot(x,y,type="n", axes=F) > points(x,y, pch="$",cex=0.7, col=z) > axis(1, col="green", col.axis="green") > axis(2, col="red", col.axis="red") > > # Draw the box like an "L" on the bottom and left only > box(bty = "l") > > > Note that you can specify which sides the 'box' is created upon by using > the 'bty' argument. See ?box for more information. Thanks, I did not find bty under ?box, but found it under par after you pointed it out. That does not get the correct output, however, because the black box covers over my 2 different colored axes. Even if I weren't color-conscious, it gives me this: | | |_______ not crossed axes, which I want: | | _|______ | I'm putting in a seed so we will both see the same things in this example. set.seed(1233240) x <- rnorm(100) z <- gl(2,50) y <- rnorm(100, mean= 1.8*as.numeric(z)) plot(x,y,type="n", axes=F) points(x,y, pch="$",cex=0.7, col=z) axis(1, col="green", col.axis="green") axis(2, col="red", col.axis="red") # MS recomends: # Draw the box like an "L" on the bottom and left only box(bty = "l") > > Also, by default, the axes extend the range of 'x' and 'y' by 4%. You > can use 'xaxs = i' and 'yaxs = i' in the plot() call to restrict the > axes to the true ranges of 'x' and 'y'. This would be important, for > example, when you want the lower left hand corner of the plot to be at > exact coordinates such as 0,0. I would be delighted if the axes really did reach 4% outside the data. But they don't. I've seen that same thing you are referring to in the documentation, but there's something wrong about it, In my example code, we should see the same thing now I've put in a seed. The axes are smaller than the data range, not equal to 1.04 times the data range. I see several observations in the graph that are "off the charts", they are above the highest value of the y axis, or below the lowest axis value. Similarly, there are observations smaller than the low end of the x axis and bigger than the largest x axis value. The 4% may be the plot region's size, but it is surely not the length of the axis that is drawn? > > See ?par for more information. > > HTH, > > Marc Schwartz > > -- Paul E. Johnson Professor, Political Science 1541 Lilac Lane, Room 504 University of Kansas ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.