Rank: 72376 based on 0 downloads (last 30 days) and 0 file submitted
photo

Wyllian

E-mail
Company/University
UTFPR

Personal Profile:
Professional Interests:

 

Watch this Author's files

 

Comments and Ratings by Wyllian View all
Updated File Comments Rating
09 Aug 2012 subindex Label subplots with index in top left corner Author: David Lamper

Modification with label position:

subindex('letter','r','t'); % r|l = right|left; b|t = bottom|top

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function H=subindex(method,lr,bt)

function H=subindex(method,lr,bt)
%SUBINDEX Label subplots with an index (e.g. a,b,c)
% SUBINDEX labels subplots in the current figure with an index in
% the top left corner.
%
% SUBINDEX(METHOD) labels subplots with an index defined by METHOD.
% Options are:
% METHOD = 'letter' : a, b, c, etc. (default)
% 'number' : 1, 2, 3, etc.
% 'roman' : i, ii, iii, etc.
%
% See also SUBPLOT.

% Author: David Lamper - david.lamper@gmail.com
%
% v 1.0 - Mar 2006


% Default index method is letter
if nargin == 0
method = 'letter';
end

% get axis handles
ax=get(gcf,'children');
ax = flipud(ax);
h = zeros(1,length(ax));

% only count up to 20 in roman numerals
if strcmpi(method,'roman')
if length(ax) > 20
warning('Roman numerals only supported for less than 20 axes.');
end
end

for i=1:length(ax)
axes(ax(i));

switch lower(method)
case 'letter'
if (strcmp(lr,'r') )
string = ['(' 'a'+i-1 ' '];
else
string = [' ' 'a'+i-1 ')'];
end
case 'number'
if (strcmp(lr,'r') )
string = ['(' '1'+i-1 ' '];
else
string = [' ' '1'+i-1 ')'];
end
case 'roman'
if (strcmp(lr,'r') )
string = ['(' rnum(i) ' '];
else
string = [' ' rnum(i) ')'];
end
otherwise
error('Unknown method');
end

% determine if there is already a subindex label on the axis
if length(getappdata(ax(i), 'subindexLabelHandle')>0)
hold = getappdata(ax(i), 'subindexLabelHandle');
delete(hold);
end

if (strcmp(lr,'r') && strcmp(bt,'b') ) % corner bottom right
h(i) = text(1,0,string,'units','normalized','verticalalignment','bottom','HorizontalAlignment','right');
elseif (strcmp(lr,'r') && strcmp(bt,'t') ) % corner top right
h(i) = text(1,1,string,'units','normalized','verticalalignment','top','HorizontalAlignment','right');
elseif (strcmp(lr,'l') && strcmp(bt,'b') ) % corner bottom left
h(i) = text(0,0,string,'units','normalized','verticalalignment','bottom','HorizontalAlignment','left');
elseif (strcmp(lr,'l') && strcmp(bt,'t') ) % corner top left
h(i) = text(0,1,string,'units','normalized','verticalalignment','top','HorizontalAlignment','left');
end

% set handle as application data
setappdata(ax(i), 'subindexLabelHandle', h(i));
end

% return text handles
if nargout == 1
H = h;
end

% ------------------------------------------------------------------------
function s=rnum(x)
% Convert x to roman numerals.
%
% Use a simple lookup table

roman = {'i','ii','iii','iv','v','vi','vii','viii','ix','x','xi', ...
'xii','xiii','xiv','xv','xvi','xvii','xviii','xix','xx'};
nroman = 20;

% prevent error if x > length(roman)
s = roman{min(x,nroman)};

09 Aug 2012 subindex Label subplots with index in top left corner Author: David Lamper

How apply on bottom right corner?

regards

08 Aug 2012 Panel Like subplot, but easier, and WYSIWYG export to file. Also fixes dashed/dotted lines in export. Author: Ben Mitch

Very powerfull tool. Suitable for graphics professionals.

Contact us