How to make a Part a and Part b bar chart

2 次查看(过去 30 天)
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])

回答(1 个)

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

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Dialog Boxes 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by