如何让 ggplot 正确排序构面?

发布于 2024-09-11 04:22:32 字数 244 浏览 5 评论 0原文

我试图根据从 2 到 14 的变量对 14 个图进行分面。绘图按顺序显示: 10,11,12,13,14,15,2,3,4,5,6,7,8,9

如何让他们订购2-15?

更新:好的,所以我使用 data$var=as.factor(data$var) 将其作为一个因子。 级别是 级别:10 11 12 13 14 15 2 3 4 5 6 7 8 9

如何重新排序?

I am trying to facet about 14 plots based on a variable that runs from 2-14. The plots show up in the order:
10,11,12,13,14,15,2,3,4,5,6,7,8,9

How do I get them to order from 2-15?

update: ok, so I made it a factor using data$var=as.factor(data$var).
The Levels are
Levels: 10 11 12 13 14 15 2 3 4 5 6 7 8 9

How do I reorder those?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

老子叫无熙 2024-09-18 04:22:33

如果没有您的数据,我最好的猜测是将您的分面变量转换为一个具有您想要的顺序级别的因子。

Without your data, my best guess would be to turn your faceting variable into a factor that has the levels in the order which you desire.

安静被遗忘 2024-09-18 04:22:32
data$var <- factor(data$var, levels = sort(unique(data$var)))
data$var <- factor(data$var, levels = sort(unique(data$var)))
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文