Why can you make ticks across x-axis but not y-axis in ggplot?

Viewed 38

In ggplot you can make ticks cross the x-axis with

ggplot(mtcars, aes( mpg, wt)) + geom_point() + theme( axis.text = element_blank(), axis.ticks.length.x = unit(c(-.5,.5), "cm"))

cross-x axis

The same code for y axis doesn't seem to work. I thought it was a issue with margins but that doesn't seem to be the case.

ggplot(mtcars, aes( mpg, wt)) + geom_point() + theme( axis.text = element_blank(), axis.ticks.length.y = unit(c(-.5,.5), "cm"))

y-axis fail

1 Answers

This appears to work on my end. Are you using the latest version of ggplot2 and the default theme?

update.packages(oldPkgs = "ggplot2")
theme_set(theme_gray())
Related