matlab - Setting boxplot properties -
i trying adjust heights of boxplot. simple example:
boxplot(1:10,[zeros(1,5) ones(1,5)], 'colorgroup', [0 1], 'colors', 'rb', 'orientation', 'horizontal') h = findobj(gcf, 'tag', 'box'); ydata = get(h, 'ydata'); celldisp(ydata); ydata{1} = ydata{1}*0.60; % adjust height set(h, 'ydata', ydata); note celldisp(ydata) displays:
ydata{1} = 1.8500 1.8500 2.1500 2.1500 1.8500 ydata{2} = 0.8500 0.8500 1.1500 1.1500 0.8500 and above code gives error:
error using set conversion double cell not possible. how set 'ydata', cell?
please note, simplified extraction more complicated code. in general, elements of cell ydata not same length, hence cannot use cell2mat or on ydata
it turns out h array of handles, since there multiple objects in figure.
thus, manipulations must performed in each entry in array h separately.
e.g.
ydata = get(h(1), 'ydata'); % stuff ydata, set(h(1), 'ydata', ydata); ydata = get(h(2), 'ydata'); % stuff ydata, set(h(2), 'ydata', ydata);
Comments
Post a Comment