Prev: openGL bug
Next: Sptool Spectral analysis
From: Tom Lane on 13 Apr 2010 13:37 > p1=boxplot(bxplt_data2,'orientation','horizontal','label',bxplt_lbl,'colors','b','symbol','b+'); > hold on > p2=boxplot(bxplt_data1,'orientation','horizontal','label',bxplt_lbl,'colors','r','symbol','r+'); > legend([p1,p2],M); > ***************** > Error: > ??? Operands to the || and && operators must be convertible to logical > scalar values. One issue is that the two boxplot commands each return a matrix of handles to different parts of the boxes. The legend function isn't expecting you to pass in a matrix of handles. You might find it easier to approach this way: M={'Test A','Test B'}; X1 = randn(30,3); X2 = 10+randn(30,3); pos = [(1:size(X1,2)), (1:size(X2,2))]; p1=boxplot([X1 X2],'orientation','horizontal','label',{'#1' '#2' '#3' '' '' ''},... 'symbol','+','pos',pos,'color','rb'); legend(p1(1,[1 2]),M); -- Tom
From: Anbazhagan on 15 Apr 2010 05:44
This appraoch doesnt work either. I get two errors. First I get an error message saying that 'Incorrect Number of labels'. My labels have only thirty values. Matlab needs sixty values to plot. So instead of one '#1' label there are two '#1' labels. I want the two boxplots to share the same labels which is not possible with this approach i guess. "Tom Lane" <tlane(a)mathworks.com> wrote in message <hq2a4r$4vj$1(a)fred.mathworks.com>... > > p1=boxplot(bxplt_data2,'orientation','horizontal','label',bxplt_lbl,'colors','b','symbol','b+'); > > hold on > > p2=boxplot(bxplt_data1,'orientation','horizontal','label',bxplt_lbl,'colors','r','symbol','r+'); > > legend([p1,p2],M); > > ***************** > > Error: > > ??? Operands to the || and && operators must be convertible to logical > > scalar values. > > One issue is that the two boxplot commands each return a matrix of handles > to different parts of the boxes. The legend function isn't expecting you to > pass in a matrix of handles. > > You might find it easier to approach this way: > > M={'Test A','Test B'}; > X1 = randn(30,3); > X2 = 10+randn(30,3); > pos = [(1:size(X1,2)), (1:size(X2,2))]; > p1=boxplot([X1 X2],'orientation','horizontal','label',{'#1' '#2' '#3' '' '' > ''},... > 'symbol','+','pos',pos,'color','rb'); > legend(p1(1,[1 2]),M); > > -- Tom > |