Plotting with categorical data
Show older comments
Plotting a bar chart with a categorical vector on the x-axis and a double vector on the y-axis.
The resulting bar chart is alphabetically arranged (by default) by the categorical vector on the x-axis.
How does one arrange the bar chart with highest to lowest values from the double vector on the y-axis ?
R, Shaun
Accepted Answer
More Answers (1)
Walter Roberson
on 11 May 2020
[sy, syidx] = sort(y, 'descend');
cc = categorical(1:length(y), 1:length(y), string(x(syidx)));
plot(cc, sy);
Categories
Find more on Data Distribution Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!