ggplot语法
ggplot(mydata,aes(x=sample,y=num,fill=type))+
geom_bar(stat = 'identity',position = 'stack',color = 'white',width = 0.6)+
geom_text(aes(label=num),position = position_stack(vjust = 0.5),color='white',size=4)+
xlab('Hours after ETH treatment') +
ylab('Number of significantly DEGs')+
####### 添加参考线
#geom_hline(yintercept = totals,colour = 'gray',linetype='dashed',size = 0.5) +
########### 填充颜色
scale_fill_brewer(palette = "Set1")+
#scale_fill_manual(values=alpha(c("#FFA500","#6495ED"), 1))+
############# 删除背景和刻度线
theme_bw() +
theme(panel.grid = element_blank())+ ###删除网格线
#theme(axis.text = element_blank()) + ## 删去刻度标签
theme(axis.ticks.x = element_blank()) + ## 删去刻度线
theme(panel.border = element_blank()) + ## 删去外层边框
theme(axis.title = element_text(size = 10))+
theme(axis.text = element_text(size = 10,color = 'black'))+
############# 加边框和自定义y轴刻度
theme(axis.line = element_line(size = 0.5,color = 'black'))+
scale_y_continuous(breaks=c(0,730,837,1046,1453),
labels=c(0,730,837,1046,1453),
limits = c(0,1500),
expand = c(0,6)) +
############### 图例
theme(legend.position = c(0.2,0.95))+
guides(fill=guide_legend(title = NULL)) +
theme(legend.key.size = unit(12, "pt"),
legend.key.height = unit(12, "pt"),
legend.key.width = unit(12, "pt"),
legend.text = element_text(size = 10))