data<-read.csv("cdr15.csv",header=T)
library(ggplot2)
library(reshape2)
data_m=melt(data)
# variable和value为矩阵melt后的两列的名字,内部变量, variable代表了点线的属性,value代表对应的值。
#箱线图
#p1<-ggplot(data_m,aes(x=variable,y=value),color=variable)+
# geom_boxplot(aes(fill=variable))
#violin plot
p2<-ggplot(data_m,aes(x=variable,y=value),color=variable)+
geom_violin(aes(fill=variable))+
theme(axis.text.x = element_text(size = rel(1.2)))+ #调整横轴文本的大小,角度angle=90
labs(x="",y="length",title="The distribution of CDR2,3 length when CDR1 length is 5") #添加横纵轴名称
效果图
参考 http://blog.csdn.net/qazplm12_3/article/details/76474663
http://blog.csdn.net/lilanfeng1991/article/details/34859799