代码之家  ›  专栏  ›  技术社区  ›  Geet

如何从y轴值中删除面值,同时使用tidytext中的reorder_within对每个面内的盒图进行排序?

  •  0
  • Geet  · 技术社区  · 4 年前

    如何从y轴值中删除面值,同时使用tidytext中的reorder_within对每个面内的箱图进行排序?

    这是我的代码:

    library(tidyverse); library(tidytext)
    
    mpg %>% 
      ggplot(aes(x = hwy, y = reorder_within(trans, hwy, class, median))) + 
      geom_boxplot() +
      facet_wrap(~class, scales = "free_y")
    

    这些是我想删除的方面值。

    enter image description here

    0 回复  |  直到 4 年前
        1
  •  2
  •   Wolfgang Arnold    4 年前

    您需要添加 scale_y_reordered() :

    library(tidyverse); library(tidytext)
    
    mpg %>% 
      ggplot(aes(x = hwy, y = reorder_within(trans, hwy, class, median))) + 
      geom_boxplot() +
      scale_y_reordered() +
      facet_wrap(~class, scales = "free_y")
    
    推荐文章