histogram with three sets of data

3 views (last 30 days)
Hello, I've been trying to program a set of three sets of data in one plot to be able to compare it. An example of something I would like is the following:

Accepted Answer

dpb
dpb on 4 Dec 2020
So what have you tried? Did you read the doc for bar and look at examples?
XData=categorical({'Category A','Category B','Category C'});
YData=abs(randn(3)); % some arbitrary data
hB=bar(XData,YData,'grouped','BarWidth',1); % plot the bar
hold on % ready to add more to same axes
hL=plot(XData,mean(YData,2),'-','LineWidth',2); % the line
hLg=legend('Inferior','Superior','Medical','Area','Location',"southoutside",'Orientation',"horizontal");
Above for the particular sample of data produced:
Salt to suit details with your data...

More Answers (0)

Community Treasure Hunt

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

Start Hunting!