I am trying to make a bar graph with two different groups. I have done almost everything, but I am trying to add a legend for group, but can only successfully get one legend to be labeled. My data is two columns.
Here is my code:
y=datain;d1mean=mean(datain(:,1));d2mean=mean(datain(:,2));d1std= std( datain(:,1) ) / sqrt( length( datain(:,1) ));d2std= std( datain(:,2) ) / sqrt( length( datain(:,2) ));figureholdhb =bar(d1mean,'BarWidth',.75);pause(0.1);set(hb(1), 'FaceColor','b')errorbar(d1mean,d1std,'k.');xdata2=2;hb =bar(d2mean,'BarWidth',.75,'Xdata',xdata2);pause(0.1);errorbar(xdata2,d2mean,d2std,'k.');set(hb(1), 'FaceColor','r')hold onhbc = get(hb, 'Children');legend(hbc,'Correct','Not Correct');
Here is my data for this figure:
datain = -0.000271345000000000 -0.000267704000000000-0.000301474000000000 -0.000344932000000000-1.52000000000000e-05 -3.51000000000000e-05-2.36000000000000e-05 -3.41000000000000e-05-3.67000000000000e-06 -0.000107296000000000-0.000155831000000000 -0.0002573190000000003.86000000000000e-05 -4.28000000000000e-054.48000000000000e-05 -0.000155381000000000-9.51000000000000e-05 -0.002000640000000000.000132163000000000 -0.00133529700000000-0.000193404000000000 9.84000000000000e-050.000191851000000000 -0.0001746650000000009.88000000000000e-05 8.33000000000000e-050.00182427300000000 0.000713032000000000-0.000626424000000000 0.003822251000000000.000407865000000000 0.000141848000000000-0.000217450000000000 -0.000293288000000000-4.02000000000000e-05 -0.0002033700000000000.000843427000000000 -0.0001524650000000000.00100842500000000 0.000150815000000000-0.000390770000000000 0.0003630630000000000.000187511000000000 -0.0001904160000000004.42000000000000e-05 9.53000000000000e-06-0.000350348000000000 0.000440978000000000-4.52000000000000e-05 1.89000000000000e-05-1.13000000000000e-05 7.46000000000000e-05-0.00118165100000000 -2.48000000000000e-05-0.000601596000000000 -0.000942368000000000-0.000663966000000000 -0.0005722820000000000.00332484100000000 0.0003162770000000006.92000000000000e-05 -0.000125089000000000-0.000190756000000000 -9.53000000000000e-05-0.00175938700000000 -0.0004076730000000000.00357178000000000 -0.000382842000000000-0.0360602630000000 -0.01501186000000000.0170111500000000 0.003356339000000000.00188138800000000 -0.00180161300000000-0.000870726000000000 -0.00221083000000000-0.000154684000000000 0.00318132900000000-0.00110678900000000 -0.001607833000000000.000142479000000000 -0.000337943000000000-3.60000000000000e-05 -4.76000000000000e-05-0.00649187900000000 -0.00548735400000000-0.00340032800000000 0.01065019500000000.000808602000000000 0.00116598700000000-0.000303465000000000 2.26000000000000e-05-0.000118639000000000 -0.000186277000000000-0.000243804000000000 0.000100178000000000-0.00108102300000000 0.000255303000000000-0.000737168000000000 -0.000227166000000000-0.000272970000000000 -5.82000000000000e-05-1.46000000000000e-05 -0.000279268000000000-0.000105326000000000 -0.000150069000000000-4.63000000000000e-05 -9.56000000000000e-06-0.000184068000000000 0.000430325000000000-0.000507061000000000 -0.001014892000000000.000216693000000000 0.0003166120000000007.38000000000000e-05 0.0001100010000000000.000182687000000000 -0.0007741680000000000.00200378300000000 -0.0009330460000000000.000218153000000000 0.000509206000000000-7.62000000000000e-05 5.11000000000000e-05-4.06000000000000e-05 -0.0005555620000000008.81000000000000e-05 -0.000788831000000000-0.000188799000000000 0.001462557000000000.000222302000000000 4.85000000000000e-05-0.000124519000000000 -0.000159541000000000-0.000151391000000000 -0.000198232000000000-0.000809613000000000 -0.000139193000000000-0.000227146000000000 0.000418432000000000-0.000153166000000000 3.34000000000000e-05-3.11000000000000e-05 0.0005895890000000000.00456111100000000 -0.00411876500000000-0.00191101400000000 -0.002614103000000006.28000000000000e-05 -0.0004522290000000000.000285205000000000 -0.0004495520000000002.60000000000000e-05 -5.48000000000000e-05-7.52000000000000e-05 9.31000000000000e-050.000389031000000000 6.93000000000000e-05-0.000428742000000000 -6.89000000000000e-050.00125381300000000 -0.000288931000000000-0.000254823000000000 -0.000501194000000000-0.000108110000000000 -0.000217084000000000-0.000178516000000000 0.000500603000000000-0.000109677000000000 0.000173589000000000-0.000128441000000000 -3.04000000000000e-05
Here is what my figure is coming out as:
How do I get the not correct to be red?
Best Answer