ggplot2绘图指定x轴因子水平顺序

 

1、

library(gcookbook)
library(ggplot2)
p=ggplot(heightweight,aes(x=sex,y=heightIn))+geom_violin()
p

 

 

2、指定x轴因子水平顺序

heightweight$sex<-factor(heightweight$sex,levels = c("m","f"))
p=ggplot(heightweight,aes(x=sex,y=heightIn))+geom_violin() p

 

posted @ 2021-01-10 13:11  小鲨鱼2018  阅读(2444)  评论(0编辑  收藏  举报