MATLAB: Changing bar color to black and white

barmatlab barplotrgb code

Hello every body
I want to change the color of a bar element to black and white, I don't know how to use the RGB codes of the colors.
bar(mydata, ' stacked ', 'color' , 'DimGray');
As I googled I find '65 65 65' for RGB code of 'dimGray' , and also I used
bar(mydata, ' stacked ', 'color' , [ 65 65 65 ]);
but it doesn't work out.
Could anyone help me in this issue?
Appreciate your kind help.

Best Answer

Hi Vahid_68,
the function bar does not support your command. Colors have to be given as normalized values in the range [0..1] and there is no property 'color'.
One way (even though you cannot distinguish matched segments) is to call the following commands:
x = rand(5);
bar(x,'stacked','FaceColor',[0.65 0.65 0.65])
That gives you a grey faced bar with 5 segments each.
Kind regards,
Robert