different colors for each bar in stacked bar graph - base graphics
问题 I want to plot a stacked bar graph like the one attached, but I want the colors to vary between the categories aa, bb and cc. Specifically, I want the grey blocks in bb to be red and the grey blocks in cc to be green. The following code serves as a simple example and illustrates what I have already tried: aa=c(0.2,0.6,0.1,0.1) bb=c(0.4,0.5,0.05,0.05) cc=c(0.5,0.25,0.1,0.15) x=cbind(aa,bb,cc) x #the data aa bb cc [1,] 0.2 0.40 0.50 [2,] 0.6 0.50 0.25 [3,] 0.1 0.05 0.10 [4,] 0.1 0.05 0.15