how to plot different horizontal lines over each group of bar plot
Show older comments
Accepted Answer
More Answers (1)
Here's a demo -
%Random data
mat = randi([11 19], 4, 6);
%Bar plot
b = bar(mat);
hold on
%Get the x-coordinates of each group (center of each bar)
%Each column represents the x-coordinates of each bar group
x = vertcat(b.XEndPoints)
%Get the coordinates of the end points
x = x([1 end],:).'
plot(x, [5 5], 'LineWidth', 2.5, 'Color', 'k');
hold off
Categories
Find more on Annotations 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!




