代码之家  ›  专栏  ›  技术社区  ›  stackinator Brenton Wiernik

增加蜱痕和Y轴值之间的间距

  •  0
  • stackinator Brenton Wiernik  · 技术社区  · 6 年前

    - 我的Y轴上的刻痕 % 不同值的符号?

    library(tidyverse)
    mtcars %>% 
      count(cyl) %>% 
      mutate(prop = n / sum(n)) %>% 
      ggplot(aes(x = cyl, y = prop)) + 
      geom_point() + 
      scale_y_continuous(labels = scales::percent)
    

    它们现在看起来是这样的:

    40.0%-
    35.0%-
    30.0%-
    25.0%-
    

    我更喜欢这样:

    40.0% -
    35.0% -
    30.0% -
    25.0% -
    
    1 回复  |  直到 6 年前
        1
  •  0
  •   NelsonGon phoxis    6 年前

    试着调整一下主题。下面是一个尝试:

    mtcars %>% 
      count(cyl) %>% 
      mutate(prop = n / sum(n)) %>% 
      ggplot(aes(x = cyl, y = prop)) + 
      geom_point() + 
      scale_y_continuous(labels = scales::percent)+
      theme(axis.ticks.length =unit(1.5,"mm"),axis.ticks.y = element_line(size=0.5))