MATLAB Answers

Erik J
0

Black and Grey Bars in Barplot

Asked by Erik J
on 2 Apr 2019
Latest activity Edited by dpb
on 3 Apr 2019
Accepted Answer by dpb
Hello,
I have a barplot with two groups plotted next to each other (see code below). I cannot for the life of me get the bars to be black and white - they are always printing as the default red/blue, despite what I think is code that should work. Any help is much appreciated. Thank you!
subplot(2,2,1)
clr = [0 0 0; 0.9 0.9 0.9];
colormap(clr);
a = [percentsQ1' percentsQ1N'];
bar(a);

  0 Comments

Sign in to comment.

Products


Release

R2018b

1 Answers

dpb
Answer by dpb
on 2 Apr 2019
Edited by dpb
on 3 Apr 2019
 Accepted Answer

Need to apply the colormap to something...
hAx=subplot(2,2,1);
clrs = [0 0 0; 0.9 0.9 0.9];
colormap(hAx,clrs);
hB=bar([percentsQ1' percentsQ1N']);
or you can use set() to set the bar handle properties directly...
set(hB,{'FaceColor'},{clrs(1,:),clrs(2,:)}.')

  1 Comments

Erik J
on 3 Apr 2019
Thank you very much!

Sign in to comment.



Translated by