ggplot2中boxplot的顺序 [英] Order of boxplot in ggplot2

查看:68
本文介绍了ggplot2中boxplot的顺序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的代码:

> hdata$Mono<- factor(hdata$Mon)

> ggplot(hdata, aes(y= Test1, x= Mono))+ geom_boxplot()

这就是它的作用:

我想以某种方式设置x轴的格式,使其从12开始,像这样12、1、2、3、4、5、6、7、8

I want to format the x axis in a way so that it will start from 12 and go like this 12, 1, 2, 3, 4, 5, 6 ,7, 8

推荐答案

只要做

hdata$Mono<- factor(hdata$Mon, levels = c(12, 1:8))

默认情况下,

factor以升序对级别进行排序.您可以使用 levels 自变量对它们进行排序.

factor by default orders the levels in ascending order. You can order them yourself by using the levels argument.

这篇关于ggplot2中boxplot的顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆