本文介绍了重新排序()不正确地重新排序ggplot中的一个因子变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 set.seed(200)$我很困惑为什么这些箱子不会在这个图上订购: b $ bx rep(USA,10), rep(Ireland,5)), wing = c(rnorm(25))) ggplot(x,aes(reorder(country,wing,median),wing))+ geom_boxplot() 如何根据最高的最低中位数(从左到右)排序箱型图?解决方案因为你没有使它成为一个有序的因素。尝试 ggplot(x,aes(reorder(country,wing,median,order = TRUE),wing))+ geom_boxplot ) I'm baffled as to why the boxplots are not ordering in this plot:set.seed(200)x <- data.frame(country=c(rep('UK', 10), rep("USA", 10), rep("Ireland", 5)), wing=c(rnorm(25)))ggplot(x, aes(reorder(country, wing, median), wing)) + geom_boxplot()How can I order the boxplots based on highest-lowest medians (left to right)? 解决方案 Because you did not make it an ordered factor. Tryggplot(x, aes(reorder(country, wing, median, order=TRUE), wing)) + geom_boxplot() 这篇关于重新排序()不正确地重新排序ggplot中的一个因子变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
09-22 14:46