I tried plotting bar graphs of cumulative rainfall for the months of june, july and august (13 weeks) of 6 consecutive years in matlab using for loop. I used hold on function to get all the plots in a single graph. But instead of getting a side-by-side bars, I got bar graphs stacked on top. Please help me create a side-by-side graph.
This is the code I used
clear all
a=[1:1:13]
list=dir('*.TXT')
for i=1:13(list)
f=list(i).name
rain_cum(i)=textread(f)*649.2/1420000
end
bar(a,cumsum(rain_cum))
xlabel=('Weeks');
ylabel=('Rainfall');
hold on
list=dir('*.TXT')
for i=14:26(list)
f=list(i).name
rain_cum(i-13)=textread(f)*649.2/1420000
end
bar(a,cumsum(rain_cum))
xlabel=('Weeks');
ylabel=('Rainfall');
hold on
list=dir('*.TXT')
for i=27:39(list)
f=list(i).name
rain_cum(i-26)=textread(f)*649.2/1420000
end
bar(a,cumsum(rain_cum))
xlabel=('Weeks');
ylabel=('Rainfall');
hold on
list=dir('*.TXT')
for i=40:52(list)
f=list(i).name
rain_cum(i-39)=textread(f)*649.2/1420000
end
bar(a,cumsum(rain_cum))
xlabel=('Weeks');
ylabel=('Rainfall');
hold on
list=dir('*.TXT')
for i=53:65(list)
f=list(i).name
rain_cum(i-52)=textread(f)*649.2/1420000
end
bar(a,cumsum(rain_cum))
xlabel=('Weeks');
ylabel=('Rainfall');
hold on
list=dir('*.TXT')
for i=66:78(list)
f=list(i).name
rain_cum(i-65)=textread(f)*649.2/1420000
end
bar(a,cumsum(rain_cum))
xlabel=('Weeks');
ylabel=('Rainfall');
legend({'y=2013','y=2014','y=2015','y=2016','y=2017','y=2018'},'location','northwest')
hold off
This is what I got