MATLAB: How to change bar color

barchangecolor

Hi, I have this simple graph already represented but now I would like to change WT n/e and WT w/e into white color and the M n/e and M w/e into black. I´ve been trying many things without succsess.
c = categorical ({'WT n/e','WT w/e','M n/e','M w/e'});
pix = [1.4 3.8 1.5 4.4];
bar(c,pix)
c = categorical ({'WT n/e','WT w/e','M n/e','M w/e'});
pix = [1.4 3.8 1.5 4.4];
bar(c,pix)
Thanks in advence.

Best Answer

This works:
c = categorical ({'WT n/e','WT w/e','M n/e','M w/e'});
pix = [1.4 3.8 1.5 4.4];
bar(c,pix);
hold on
bar(c, [pix(1:2) NaN NaN], 'w')
bar(c, [NaN NaN pix(3:4)], 'k')
hold off