如何从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")
这些是我想删除的方面值。
您需要添加 scale_y_reordered() :
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")