XTick labels for bar plot of 2 data sets
Afficher commentaires plus anciens
I want to make a bar chart with 2 data sets that have different number of values and I want each set to have the same color. Example code:
figure, bar([1:5],rand(1,5),'b'); hold on
bar([6:12],rand(1,7),'r')
The bar chart shows the XTickLabels for the first data set but not the second. How do I get XTickLabels for all 12 bars?
If I make a bar chart with a dataset with 12 entries, I can't change the colors of some bars, for example bars 1 - 5, so I had to break it up and make 2 bar plots.
Hope this makes sense.
Thanks!

Réponse acceptée
Plus de réponses (1)
You can modify the colour of individual bars in the bar chart using CData.
This documentation explains it well:
Here is an example of how you could implement it:
b = bar([rand(1,5),rand(1,7)]); % Create bar chart.
b.FaceColor = 'flat';
b.CData(6:end,:) = repmat([1 0 0],7,1); % Choose bars to change colour to red.
1 commentaire
VB ABQ
le 30 Jan 2019
Catégories
En savoir plus sur Discrete Data Plots dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
