Commit eaa03183 by Chiara Antonini

Upload new file

1 parent ba6d9e4d
%% boxplot_label_edit_example_for_file_exchange.m
%
% Michael Serafino
% created 6/5/13
%
% This code shows how to change the position of the text labels for the
% boxplot function. It also shows how to make the changes persist and
% resize when the figure is resized.
%
% This code was inspired by the following:
%
% 1.
% "When using box plot, why do I lose changes in text annotation positions
% when resizing my figure in MATLAB 7.8 (R2009a)?"
% http://www.mathworks.com/support/solutions/en/data/1-A8WRLK/index.html?product=ML&solution=1-A8WRLK
%
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
%plot
b=boxplot(MIRIT);
ylabel('MIRI');
%get the text labels
textobjs=findobj(gca,'type','text');
%set(textobjs,'Interpreter','tex');
%rotate the text
%set(textobjs,'rotation',45);
%change the font size
set(textobjs,'fontsize',15);
for t=1:39
for i=1:size(b,1)
set(b(i,t),'linewidth',2.5);
end
end
%change the position of the text
offset_amount = [0 -3 0];
temptextpositions = get(textobjs,'position');
for n = 1 : length(textobjs)
set(textobjs(n),'position',get(textobjs(n),'position')+offset_amount);
end
%this makes it so that the labels will stay in the same relative position
%on the figure, scaling when the figure is resized
set(textobjs,'units','data');
%code from source 1. This does something conceptually equivalent to
%removing the link that the text has to the boxplot, creating a copy of the
%text, and deleting the original text. (correct me if I'm wrong).
copyobj(textobjs,gca);
delete(textobjs);
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!