Is it possible that the older legend is present but hidden underneath the
newer one? Did you specifically use different positions in the legend() function ?
yes. it is hidden underneath. Am using the 'best' position for both legends.
Well, change your code so that you use different specific corners.
legend() does not look at the graphics drawn already in order to find
the best place: it only looks at the data values of the axis it is
associated with.
I tried your suggestion but the first legend flashes for a second and then disappears.
Then it displays only one legend but it is wrong i.e; it displays second boxplot legend text with the first boxplot line color.
I tried this approach but I receive an error
M={'Test A',Test B'};
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.
Error in ==> legend at 198
elseif narg > 0 && ~ischar(varargin{1}) && ...
*****************
The above approach works well for the normal plots.
I dont know what I am doing wrong with boxplots.
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
"Tom Lane" <tl...@mathworks.com> wrote in message <hq2a4r$4vj$1...@fred.mathworks.com>...