Example from Bar Graph Plot doesn't function in R2019a #categorical

1 vue (au cours des 30 derniers jours)
Franciszek Aniol
Franciszek Aniol le 6 Mar 2022
When i try the example code:
X = categorical({'Small','Medium','Large','Extra Large'});
X = reordercats(X,{'Small','Medium','Large','Extra Large'});
Y = [10 21 33 52];
bar(X,Y)
from: https://de.mathworks.com/help/matlab/ref/bar.html @ Specify Categorical Data
i get this:
Error using bar (line 222)
Data inputs must match the axis configuration. A numeric axis must
have numeric data inputs or data inputs which can be converted to
double.
Error in Untitled (line 5)
bar(X,Y)
My use case is this following Bar Plot:
Due to how bar plot is configured i find it, much more different to access each bar seperately.
With my code ending as such:
b = bar(data_total.x , data_total.mean,'FaceColor','flat');
random.a = 0;
random.b = 1;
for n = 1:6
random.r = (random.b-random.a).*rand(3,1) + random.a;
b.CData(n,:)= random.r;
end
er = errorbar(data_total.x , data_total.mean, data_total.errhigh, data_total.errlow);
er.Color = [0 0 0];
er.LineStyle = 'none';
Is there a more elegant solution to make the graph easier to read in this case?
Can I plot multiple bar graphs in to a single plot?
If not how do I write 'strings' / text in the x axis of this bar plot?
with regards,
Franek

Réponses (0)

Produits


Version

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by