Effacer les filtres
Effacer les filtres

Black and Grey Bars in Barplot

19 vues (au cours des 30 derniers jours)
Erik J
Erik J le 2 Avr 2019
Modifié(e) : dpb le 3 Avr 2019
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);

Réponse acceptée

dpb
dpb le 2 Avr 2019
Modifié(e) : dpb le 3 Avr 2019
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 commentaire
Erik J
Erik J le 3 Avr 2019
Thank you very much!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Colormaps dans Help Center et File Exchange

Produits


Version

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by