简体   繁体   English

R [ggplot2] 如何设置刻度大小?

[英]R [ggplot2] How to set ticks size?

I'm trying to set ticks size, but when I specify axis.ticks parameter, ticks become horizontal on both axes.我正在尝试设置刻度大小,但是当我指定 axis.ticks 参数时,刻度在两个轴上都变为水平。 For example例如

data <- data.frame(x =c(1:10), y = c(1:10) )
ggplot(data, aes(x, y)) + 
  geom_point() +
  theme(axis.ticks = element_line(size = 5))

http://prnt.sc/dlwv0i http://prnt.sc/dlwv0i

And angle parameter doesn't work.并且角度参数不起作用。

ggplot2 version 2.2.0.9000 ggplot2 版本 2.2.0.9000

Any help would be appreciated.任何帮助,将不胜感激。

You may do:你可以这样做:

ggplot(data, aes(x,y)) + 
    geom_point() + 
    theme(axis.ticks.length=unit(.25, "cm"))

This is from https://ggplot2.tidyverse.org/reference/theme.html这是来自https://ggplot2.tidyverse.org/reference/theme.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM