Saturday, January 7, 2023

Two factors bar graph



 p_shoot_biomass=ggplot(data=mean_rs ,aes(x=Fertilizer.type, y=shoot_biomass,

                                         fill=factor("") )) +  theme_bw() +

  geom_bar(width=pos,position=position_dodge(pos),stat="identity")+

  geom_errorbar(aes(ymin=mean_rs$shoot_biomass-sd_rs$shoot_biomass,ymax=mean_rs$shoot_biomass+sd_rs$shoot_biomass),

                width=pos/2,

                position=position_dodge(pos))+

    xlab("Organic amendments") +

  ylab(labs$shoot_biomass)+

  scale_fill_manual(values=c("red", "blue", "green","grey", "yellow"))+

  #scale_fill_brewer(palette="BrBG") + # color adjustment

  s.theme1+ # add x and y axis theme here

  s.theme2+ # add-legend theme here

  facet +    # third factor

  facect.t + # facet adjustment

  scale_y_continuous(limits = c(0, 10), breaks = seq(0, 10, by = 2))+

  theme(legend.position = "")+ # facet adjustment

  labs(fill = "") # correct legend title

p_shoot_biomass 

ggsave("rs_shoot_biomass.png", width = 20, height =10)

No comments:

Post a Comment