Clear Filters
Clear Filters

How to make a Part a and Part b bar chart

2 views (last 30 days)
Sally Weston
Sally Weston on 7 Jun 2017
Commented: Sally Weston on 7 Jun 2017
Hi everyone
I have a set of data that is in a Part A and a Part B style, and I would like to present it in a bar chart. Ideally the category labels would be "Part A" and "Part B", and the bars in Part A would all be one colour and the bars in Part B would all be another colour.
Please help, thanks Sally
So far I have...
Data = [3.13 3.14 3.13 3.13 3.13 3.11 3.12 3.18 3.16 3.16 3.16 3.16 3.15 3.20 3.20;... 3.14 3.14 3.15 3.15 3.18 3.11 3.11 3.11 3.11 3.11 3.12 3.10 3.11 3.12 3.18];
figure b = bar(Data,'grouped');
ylabel('Data')
ylim([3.06 3.22])

Answers (1)

KSSV
KSSV on 7 Jun 2017
partA = rand(10,1) ;
partB = rand(10,1) ;
bar(1:10,partA, 'r')
hold on
bar(11:20,partB, 'b')
  1 Comment
Sally Weston
Sally Weston on 7 Jun 2017
Thank you, how would you add the category names? so that "partA" covers bars 1:10?

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!