ggplot2 GCA SCA Recidual variances

setwd("D:/Sync/Dlm_wk/8801growth_para/data")
library(ggplot2)
df.comp<-read.csv("var_h2_compare.csv")
str(df.comp)
library(reshape2)
df.comp<-read.csv("var_h2_compare.csv")
str(df.comp)
md <- melt(df.comp, id=c("X"))
names(md)[2]<-"Traits"
names(md)[1]<-"Comp"
str(md)
# 'data.frame': 45 obs. of  3 variables:
#   $ X       : Factor w/ 5 levels "Com!Com.var",..: 4 1 5 2 3 4 1 5 2 3 ...
# $ variable: Factor w/ 9 levels "H05","DBH05",..: 1 1 1 1 1 2 2 2 2 2 ...
# $ value   : num  -0.00176 -0.14608 0.17322 -0.00118 -0.11921 ...

shape.x<-c(0,1,5,2,6)
p<-ggplot(md, aes(x=Traits,y=value,shape=Comp))+
  geom_point(size=3)+
  scale_shape_manual(limits=c("GCA_M3-M4",
                              "SCA_M3-M4",
                              "Residual_M3-M4",
                              "Nh","Bh"),
                     values = shape.x)+ #更改shape的样式 & 顺序
  labs(shape=NULL)+#移除图例标题
  geom_hline(yintercept = 0)#加一根横线
p<-p+theme_bw(base_family = "serif")
p<-p+theme(axis.title.y=element_blank()) #移除y/x轴标题
ggsave("compare.percent.wmf",width = 5,height = 3,units = "in")
ggplot2 GCA SCA Recidual variances_第1张图片

你可能感兴趣的:(ggplot2 GCA SCA Recidual variances)