When I use box() with plot() and add some axes, the line where the tick marks are attached to the axes overlays with the box lines so you see a thickened line at the axis. How do you remove this overlap?
See code and diagram for more:
x <- seq(-pi,pi,0.1)
plot(x, sin(x), axes=FALSE)
axis(side=1, at=seq(-2, 1, by = 1))
axis(side=2, at=seq(-0.5, 0.5, by = 0.3))
box()
So you can see on the x and y axis there appears to be a thicker "double" line in the center, which just looks messy.
Note: I know one way to eliminate this problem is by making axes=TRUE
, but I have a lot of specifications to add so I need to make axes=FALSE
and then add axis()
as a separate function.
You have to use col
and col.ticks
to get the desired output. Here is the code:
x <- seq(-pi,pi,0.1)
plot(x, sin(x), axes=FALSE)
axis(side=1, at=seq(-2, 1, by = 1), col = NA, col.ticks = 1)
axis(side=2, at=seq(-0.5, 0.5, by = 0.3), col = NA, col.ticks = 1)
box()
Now the plot doesn't have those double lines
Same issue has been discussed here. Thanks