I would like to change the position of the ticks of the left plot as the right one (the ticks are inside the plot).
library(ggplot2)
library(grid)
p <- ggplot(mtcars,aes(mpg,cyl))+
geom_point() +
theme(
axis.ticks.length=unit(0.5,"cm"),
axis.line = element_line(color = 'black',size=0.1),
axis.ticks.y = element_line(size=1,color='red'),
axis.text.y = element_text(hjust=0.5))

I think I can get the desired plot playing with rodents, but I am surprised that there is no easy setting to adjust the position of the ticks!
change (label change labels using the solution here ):
the setting axis.ticks.length, as mentioned, gives an almost correct solution, the axis text should also be placed closer to the axis. hjustIt does not work.
p <- ggplot(mtcars,aes(mpg,cyl))+
geom_point() +
theme(
axis.ticks.length=unit(-0.25, "cm"),
axis.ticks.margin=unit(0.5, "cm"),
axis.line = element_line(color = 'black',size=0.1),
axis.ticks.y = element_line(size=1,color='red'),
axis.text.y = element_text(hjust=0.5)) ##this don't work

source
share