Reputation: 331
When trying to add custom axes using axis.line
within theme()
in ggplot2
, the axes do not "perfectly" connect at origin. I use size=3
to see this effect better. Is there a way to fix this?
library(ggplot2)
ggplot(mpg, aes(displ, hwy, colour = class)) +
geom_point()+
theme(axis.line = element_line(color = "black", size=3))
Upvotes: 0
Views: 359
Reputation: 13863
The documentation of the element_line
function lists some parameters. Of particular interest is the parameter lineend=
. Default value is "butt"
. If you set this to "square"
it fixes the issue:
ggplot(mpg, aes(displ, hwy, colour = class)) +
geom_point()+
theme(axis.line = element_line(color = "black", size=3, lineend = 'square'))
Upvotes: 3