001、测试数据及绘图
x <- c("B","A","D","C","E") ## 测试数据顺序 y <- c(5,6,7,8,9) df <- data.frame(x = x , y = y) df library("ggplot2") ggplot(data=df,aes(x=x,y=y)) + geom_bar(stat="identity") ## ggplot2自动排序
002、手动调整顺序
## 调整因子水平 df$x <- factor(df$x,levels=c("B","A","D","C","E")) ## 绘制条形图 ggplot(data=df,aes(x=x,y=y)) + geom_bar(stat="identity") ## 按照指定顺序输出
。
标签:顺序,##,标签,002,绘图,ggplot2 From: https://www.cnblogs.com/liujiaxin2018/p/17852729.html