Bar plot with multidimensional matrix-->columns of different color
이전 댓글 표시
trial_type={'apples' 'oranges' 'banana' 'pears'};
for choice=1:4
trial_type_current = trial_type{1,choice};
Collecta=rand(10,8);
Collectb=rand(10,8);
figure(1)
subplot(2,2,choice)
hist(Collecta,10);
title(sprintf('%s',trial_type_current))
xlabel('peak location')
ylabel('frequency')
legend('s2', 'ppc' ,'lick', 'm1', 'med' ,'v1', 's1' ,'LL')
figure(2)
subplot(2,2,choice)
[n,x]=hist(Collectb,5);
for a=1:8
m=n(:,a);
bar(x,m/sum(m),'hist');hold on;
end
title(sprintf('%s',trial_type_current))
xlabel('peak amplitude')
ylabel('percentage')
legend('s2', 'ppc' ,'lick', 'm1', 'med' ,'v1', 's1' ,'LL')
end
I need to display my fig 2 histogram with the y-axis in percentages instead of frequency; I attempted to do this by using [n,x]=hist() and bar() but size(n)=5,8 and size(x)=5,1. So I used a for loop to cycle through each column one by one. The resulting figure plot, however, has the columns displayed in the same color, and overlapping each other. I would like it to look like the fig 1 histogram.
Additionally, I need to make error bars (mean +/- std) for the fig 2 histogram as well. How am I supposed to create an error matrix from the mean and std of my data, when the bar() uses values derived from hist() and it's bar() that I'm basing errorbar() off of?
댓글 수: 1
Image Analyst
2013년 11월 16일
You forgot to attach the figures or screenshots.
답변 (1개)
카테고리
도움말 센터 및 File Exchange에서 Histograms에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!