Skip to content
Prev 170461 / 398506 Next

I want axes that cross

On Fri, Feb 13, 2009 at 1:51 PM, Marc Schwartz
<marc_schwartz at comcast.net> wrote:
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")
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?