如何將圖畫成在black and white的背景下更好讀而不會丟失過多信息的策略之一:使用scale_fill_grey():
library(ggplot2)data(tips)p0=qplot(day,tip/total_bill,data=tips,geom='boxplot',fill=day)+scale_fill_grey()print(p0)
This produces the output shown below

特點:X,Y軸翻轉(zhuǎn);將默認的bar的stat為count換成了自己定義的y值;使用stack做y值的堆積而不是用fill來歸一化;可以將X軸按照自己定義要求的改變默認的顯示順序;bar圖中使用了數(shù)據(jù)集中的rank變量來做柱狀圖的顏色填充;
ggplot(t,aes(x=metric,y=percent))+geom_bar(aes(fill=rank),position="stack",stat="identity")+coord_flip()
?ggplot(t,aes(x=reorder(metric,percent,sum),y=percent))+geom_bar(aes(fill=rank),position="stack",stat="identity")+coord_flip()