【发布时间】:2018-09-22 15:43:10
【问题描述】:
我正在使用ggplot R 包,我用下面的代码做了这个图:
p3 = data.frame(cbind(c(1:70),
c("G1" , "G2" , "G1" , "G1" , "G1" , "G2" , "G1" , "G1" , "G1" , "G1" , "G1" , "G1" , "G1",
"G1" , "G1" , "G1" , "G1" , "G1" , "G1" , "G1" , "G1" , "G2" , "G1" , "G2" , "G1" , "G1" ,
"G1" , "G1" , "G1" , "G2" , "G1" , "G1" , "G1" , "G1" , "G1" , "G1" , "G1" , "G1" , "G1" ,
"G1" , "G1" , "G1" , "G1" , "G1" , "G1" , "G1" , "G1" , "G1" , "G1" , "G1" , "G1" , "G1" ,
"G1" , "G1" , "G1" , "G1" , "G2" , "G1" , "G1" , "G1" , "G1" , "G1" , "G1" , "G1" , "G1" ,
"G1" , "G1" , "G1" , "G1" , "G2"),
c(rep("B",35),rep("C",15),rep("A",20))
))
colnames(p3)=c("Num","L" , "G")
library(ggthemes)
library(ggplot2)
pp <- ggplot(p3, aes(Num, G)) +
geom_tile(aes(fill = L), colour = "white")
pp + theme(legend.position="bottom", axis.text.x = element_text(angle=90, size=7,vjust=0.5)) + # scale_fill_grey() + theme_classic()
scale_fill_manual(values=c("#990000","#E69F00","#999999"))
我想根据条数(=变量G)改变y轴值的顺序
预期情节:
非常感谢您的帮助!
【问题讨论】: