我想用ggplot2绘一幅图,要求坐标轴刻度短线朝内,我用了theme(axis.ticks.length=units(-0.5, 'cm')),结果发现,内置是内置了,但刻度标签也随之变化了,与坐标轴重叠了。查了很多资料也没找到解决方法。
dt <- data.frame(x = sample(letters[1:3], 100, replace = TRUE),
y = rnorm(100, -2, 2)
)
绘图
dt %>%
ggplot(aes(x = x, y = y)) + geom_violin() +
geom_jitter() + geom_boxplot(width = 0.5) +
theme_classic() +
theme(axis.ticks.length = unit(-0.3, 'cm'))#与x轴重叠
试了多次theme(axis.text = element_text(margin=unit()),感觉可以行的通,但一直没搞定。