在我的情节中,我试图显示5个日期中每个日期的6个机场的平均延迟时间。
这是我到目前为止的代码:
F = dataset('xlsfile','Lab2_Delta');
DATES = {'11/26/2013','11/27/2013','11/28/20113','11/29/2013','11/30/2013'};
ORIGINS = {'CVG','ORD','ATL','LAX','MIA','DFW'};
for Index = 1:6
for Index2 = 1:5
Origin_Index = find(strcmp(F.Origin,ORIGINS(Index)));
Date_Index = find(strcmp(F.Date,DATES(Index2)));
Temps(Index2,Index) = mean(F.Delay(Date_Index));
end
end
bar(1:5,Temps(:,Index)); hold on;
legend('CVG','ORD','ATL','LAX','MIA','DFW');
set(gca,'XTick',1:length(DATES));
set(gca,'XTickLabel',DATES);
ylabel('Mean Delay Times'); title('Delay Times Around Thanksgiving');
显示的图表仅显示一个机场的条形图(CVG)。我该如何展示其他城市?
答案 0 :(得分:0)
如果你可以构建一个矩阵Y
,每个日期都有一行,每个机场都有一列,那么bar(1:5,Y)
就可以了。
dates=1:5
delayCVG=rand(1,5);
delayMIA=rand(1,5)+1;
delayATL=rand(1,5)+2;
delayLAX=rand(1,5)+3;
delayDFW=rand(1,5)+4;
delayORD=rand(1,5)+5;
delay=[delayCVG' delayMIA' delayATL' delayLAX' delayDFW' delayORD'];
bar(dates,delay)