画一个柱状图,每个柱的颜色是类似于heatmap图一样的连续的颜色
数据:
activation of cells | 46 | 3.512 |
activation of macrophages | 16 | 2.519 |
activation of phagocytes | 23 | 3.032 |
immune response of phagocytes | 12 | 2.472 |
induction of cells | 16 | 1.981 |
stimulation of cells | 24 | 2.662 |
recruitment of cells | 25 | 2.785 |
cell movement | 65 | 1.325 |
cell movement of macrophages | 0 | 0 |
migration of cells | 61 | 1.808 |
chemotaxis | 21 | 2.144 |
homing of cells | 24 | 2.078 |
inflammatory response | 40 | 2.23 |
acute phase reaction | 0 | 0 |
response of macrophages | 0 | 0 |
engulfment of cells | 0 | 0 |
phagocytosis | 0 | 0 |
autophagy | 0 | 0 |
clearance of cells | 10 | 2.366 |
synthesis of nitric oxide | 13 | 1.834 |
synthesis of nitrite | 5 | 1.242 |
synthesis of eicosanoid | 0 | 0 |
metabolism of eicosanoid | 0 | 0 |
synthesis of prostaglandin E2 | 0 | 0 |
release of prostaglandin E2 | 5 | 2.227 |
cell death | 106 | 1.735 |
apoptosis | 94 | 1.133 |
apoptosis of phagocytes | 20 | 0.822 |
cell survival | 42 | 1.753 |
cell viability | 40 | 1.688 |
cell death of macrophages | 14 | 1.583 |
apoptosis of macrophages | 11 | 1.245 |
necrosis | 82 | 1.754 |
Bacterial Infections | 28 | -1.224 |
Viral Infection | 37 | -2.033 |
replication of virus | 22 | -2.352 |
mf<-read.table(pipe(“pbpaste”),sep = “\t”,header = F) #读取数据
mf\$V1 = factor(mf\$V1,levels=mf$V1) #画图时 让X轴标签顺序按输入顺序排序,而不是按字母顺序排序
ggplot(data=mf,aes(x=V1,y=V2,fill=V3)) + geom_bar(stat=”identity”,col=’gray’) + scale_fill_gradient2(“color”,low=’blue’,midpoint=0,high=’red’) + theme(axis.text.x = element_text(size=10,colour=”black”,angle = 90) ) + xlab(“”) + ylab(“Gene Number”)
自定义色bar的范围: limits(-3,3)
ggplot(data=mf,aes(x=V1,y=V2,fill=V3)) + geom_bar(stat=”identity”,col=’gray’) + scale_fill_gradient2(“color”,low=’blue’,midpoint=0,high=’red’,limits=c(-3,3)) + theme(axis.text.x = element_text(size=10,colour=”black”,angle = 90) ) + xlab(“”) + ylab(‘-log(P-value)’)
注:ggplot2颜色梯度: http://www.360doc.com/content/16/0703/00/3852985_572542419.shtml
尊重他人劳动成果,转载请注明出处:Bluesky's blog » 柱状图连续颜色填充