** Warning message: Removed 256 rows containing missing values (geom_violin).** 报错代码 **library(“ggplot2”) data <- read.table(“clipboard”,sep="\t",header = T,check.names=F) dim(data) data[1:4,1:2]
###转化因子 data m a l e < − f a c t o r ( d a t a male <-factor(data male<−factor(datamale,levels = unique(data m a l e ) , o r d e r e d = T ) d a t a male),ordered = T) data male),ordered=T)datatype <-factor(data t y p e , l e v e l s = u n i q u e ( d a t a type,levels = unique(data type,levels=unique(datatype),ordered = T)
p3<-ggplot(data, aes(male, oil,fill =type))+ geom_violin(trim=FALSE,aes(fill = type)) + geom_boxplot(position = position_dodge(width = 0.9), outlier.size = 0.9, width = 0.2, show.legend = T,outlier.shape = NA)+ #facet_wrap(~pheno,nrow=1, scales=“free_y”)+ ylim(0,0.07) + ###(0,16) (0,0.07) (0.1,0.6) guides(fill=guide_legend(title=“籽粒类型”)) + theme_bw()+ scale_fill_manual(values=c("#009E73",’#999999’))+ theme_classic()+ theme(axis.text.x = element_text(angle = 90, hjust = 0.5, vjust = 0.5),axis.text.y=element_text(size=10.5))+ labs(x = “材料类型”,y = “油分质量 g”,title="")+ ###含油率 % 油分质量 g theme(axis.title.x =element_text(size=10.5), axis.title.y=element_text(size=10.5))
p3**
正确代码
p3<-ggplot(data, aes(male, oil,fill =type))+ geom_violin(trim=FALSE,aes(fill = type)) + geom_boxplot(position = position_dodge(width = 0.9), outlier.size = 0.9, width = 0.2, show.legend = T,outlier.shape = NA)+ #facet_wrap(~pheno,nrow=1, scales="free_y")+ ***ylim(0,0.07) + ###(0,16) (0,0.07) (0.1,0.6)*** guides(fill=guide_legend(title="籽粒类型")) + theme_bw()+ scale_fill_manual(values=c("#009E73",'#999999'))+ theme_classic()+ theme(axis.text.x = element_text(angle = 90, hjust = 0.5, vjust = 0.5),axis.text.y=element_text(size=10.5))+ labs(x = "材料类型",y = "油分质量 g",title="")+ ###含油率 % 油分质量 g theme(axis.title.x =element_text(size=10.5), axis.title.y=element_text(size=10.5))需将ylim(0,0.07) 限制范围去除