简体   繁体   中英

How do I get ggplot to order facets correctly?

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?

data$var <- factor(data$var, levels = sort(unique(data$var)))

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM