If you insist on separate bar objects you can use the first part, if not, you can use the second part
figure(2),clf(2)
A=rand(10,2)*5-2.5;
Tr=A(:,1);
EPR=A(:,2);
subplot(1,2,1)
for n=1:size(A,1)
width=0.05;
h=bar(Tr(n),EPR(n),width);
hold on
if (Tr(n)<0)
h.FaceColor='r';
else
h.FaceColor='g';
end
end
subplot(1,2,2)
L=Tr<0;
EPR_part=EPR;EPR_part(~L)=NaN;
bar(Tr,EPR_part,'r'),hold on
EPR_part=EPR;EPR_part( L)=NaN;
bar(Tr,EPR_part,'g'),hold off
0 Comments
Sign in to comment.