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


浙公网安备 33010602011771号