Reputation: 64
I wanted to add an abline()
to a boxplot, but it is drawn all over the graphic and not just in the canvas. Is there a workaround?
boxplot(mpg ~ cyl, data = mtcars, main = "Car Milage Data",
xlab = "Number of Cylinders", ylab = "Miles Per Gallon")
abline(v = 2.5, col = "grey", lty = 2)
Upvotes: 1
Views: 166
Reputation: 64
Thanks to Darren Tsai whose suggestion in a comment:
Try
par(xpd = F)
and run your code again.
fixed the problem.
Upvotes: 1