Posted
Filed under 年中無休
[How to change x-axis labels' properties when using boxplot.m in Matlab]

% Let's say we have just a column of data to boxplot. We can label the data and change label properties in this way.

k = figure; boxplot(MyData,'labels',{'MyLabel'});

h = findobj(k,'string','MyLabel');  
% Now we have a handle of the object which has a property 'string' with its value 'MyLabel'.
% Without putting k, findobj will look through all the figures we have to find corresponding strings.

set(h,'fontsize',15,'fontname','times new roman');
% We can change font properties of the label 'MyLabel' with set function.

% Becasue the fontsize is bigger now, we may need to re-locate the label.

pos = get(h,'position');
% Returned variable pos has 3 components. We can change the planar label location by changing values of first two components.

set(h,'fontsize',size_you_want,'fontname','font_type_you_want','position',[pos(1) pos(2)-number_you_want]);
% Test with several numbers to fit your figure. 

% A shortcoming of this method is that we have to find the handle of each label one by one. :( Sorry for that this is the best I can provide. For multiple columns of data and labels, please utilize loop syntax.

it's irritating :(


굳이 우리말로 다시 안 써도 되겠지..?
혹시 질문 있으면 메일 주세요. :)

2010/08/04 12:03 2010/08/04 12:03