Hi all,
I'm trying to create a bar graph with error bars.
So far, my code is:
c = categorical({'CH','VC','GC','OC','BC','SC'});c = reordercats(c,{'CH','VC','GC','OC','BC','SC'});y = [707, 599; 464 444; 522 475; 566 346; 1329 1384; 459 498];std_dev = [321 271; 233 91; 202 132; 0 173; 410 850; 179 122];title('Title'); xlabel('x-label'); ylabel('y-label');figure hold onbar(c,y)errorbar(y,std_dev,'.')
The resulting graph is attached. The error bars appear to stack on top of each other, and are between the the two bars in each pair. I'm unsure how to make each error bar match with individual bars.
If it's helpful, the data in y is annual, where the first number (i.e. 707, 464, 522, 566) is Year 1 and the second number (i.e. 599, 444, 475, 346) is Year 2. The groups are further broken down so that the first three groups (c = CH, VC, GC) are one set and the last three (c = OC, BC, SC) are a second set. If possible, I would also like to have the Year 1 and Year 2 be different colors, as well as the two sets. So, for example, 707 = red, 599 = blue, 459 = green, 498 = orange.
Any help getting started is greatly appreciated!
Cheers
Best Answer