0

我正在制作一系列条形图,都与我使用以下代码生成的这个非常相似。

我看过很多关于这个的帖子,但我试图改变感兴趣的变量的顺序,但这是行不通的。有小费吗?

library(ggplot2)

trtslope<-structure(list(Geno = structure(c(5L, 5L, 5L, 5L, 5L, 5L, 5L), .Label = c("1a", "1b", "1c", "1d", "1e", "1f", "2co", "2h", "4f", "5t", "pin3", "pin3pin7"), class ="factor"), Light = structure(c(2L,2L, 2L, 2L, 2L, 2L, 2L), .Label = c("Constant","Cycle"),class = "factor"),     Trmt = structure(c(6L, 3L, 5L, 2L, 7L, 4L, 1L), .Label = c("None","10^-11Kin", "10^-10Kin", "10^-9Kin", "10^-11IAA", "10^-10IAA", 
"10^-9IAA"), class = "factor"), mean = c(-1.54504597523189, 
-1.53362395751867, -1.57385562758997, -1.54322151503139, 
-1.66574978029235, -1.32095137998064, -1.36520900266343), 
sd = c(0.46315259286543, 0.458985115845406, 0.482009142703553, 
0.641786961061545, 0.590265055416619, 0.378034730883596, 
0.400241364404397), ste = c(0.0545830565232129, 0.0564971622467328, 
0.0607274438691926, 0.0789985139281606, 0.0647900070055787, 
0.0417469522407694, 0.0292685472783953), Conc = c("10^-10", 
"10^-10", "10^-11", "10^-11", "10^-9", "10^-9", "None"), 
Group = c("IAA", "Kinetin", "IAA", "Kinetin", "IAA", "Kinetin", 
"None")), .Names = c("Geno", "Light", "Trmt", "mean", "sd", "ste", "Conc", "Group"), row.names = c(13L, 14L, 17L, 18L, 31L, 32L, 37L), class = "data.frame")

trtslopeplot<-ggplot(trtslope, aes(x=Group, y=mean, fill=Conc))+ geom_bar(stat="identity", position  = position_dodge())+geom_errorbar(aes(ymin=mean-ste, ymax=mean+ste),position=position_dodge(.9),width=.2)

#I've tried to reorder the factors as I've done in the past, but that doesn't seem to work to change the plot

trtslope$Trmt <- factor( as.character(trtslope$Trmt), levels= c("None","10^-11Kin","10^-10Kin","10^-9Kin","10^-11IAA","10^-10IAA","10^-9IAA"))
trtslope <- trtslope[order(trtslope$Trmt),]
4

0 回答 0