Adjusting bar colours in plot
18 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I am working with a bar chart that has at most 13 sub-bars per x-tick (see figure). The problem I have is that some bars appear as the same colour and I thus have no way to distinguish between them. (there are thirteen data sets I am trying to visualize, each of which can (partially)fall into 8 different categories)

I am trying to map a different set of colours to each individual bars by means of a unique RGB code. For the thirteen data entries I have here, I also have 13 unique RGB handles.
However I am unable to map the entries into the CData of the current figure, nor specify a different CData beforehand.
Below you can see the CData of the current figure:
if true
% code
%p1.CData
%ans =
%
% 0 0.4470 0.7410
% 0 0.4470 0.7410
% 0 0.4470 0.7410
% 0 0.4470 0.7410
% 0 0.4470 0.7410
% 0 0.4470 0.7410
% 0 0.4470 0.7410
% 0 0.4470 0.7410
%
%
%ans =
%
% 0.8500 0.3250 0.0980
% 0.8500 0.3250 0.0980
% 0.8500 0.3250 0.0980
% 0.8500 0.3250 0.0980
% 0.8500 0.3250 0.0980
% 0.8500 0.3250 0.0980
% 0.8500 0.3250 0.0980
% 0.8500 0.3250 0.0980%
%
%
%ans =
%
% 0.9290 0.6940 0.1250
% 0.9290 0.6940 0.1250
% 0.9290 0.6940 0.1250
% 0.9290 0.6940 0.1250
% 0.9290 0.6940 0.1250
% 0.9290 0.6940 0.1250
% 0.9290 0.6940 0.1250
% 0.9290 0.6940 0.1250
%
%
%ans =
%
% 0.4940 0.1840 0.5560
% 0.4940 0.1840 0.5560
% 0.4940 0.1840 0.5560
% 0.4940 0.1840 0.5560
% 0.4940 0.1840 0.5560
% 0.4940 0.1840 0.5560
% 0.4940 0.1840 0.5560
% 0.4940 0.1840 0.5560
end
where there are 13 of these 8 by 3 matrices(?)
I only want to ensure these bars all have a unique colour
Réponses (1)
Adam
le 9 Mar 2018
Modifié(e) : Adam
le 9 Mar 2018
Try editing the 'ColorOrder' property of your axes to define 13 colours rather than the default 7 before you do the plotting. How you determine those colours is up to you, but those are what is used for plots (and I guess for bar charts too though I rarely use bar charts).
If there are fewer colours in 'ColorOrder' than there are plot objects it just cycles round those colours endlessly.
0 commentaires
Voir également
Catégories
En savoir plus sur Data Distribution Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!