Skip to content

Commit

Permalink
Edited some functionalities.
Browse files Browse the repository at this point in the history
  • Loading branch information
dleebhsai committed Jan 29, 2019
1 parent 2b28159 commit 934499b
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Src/CommonTools/struct2array.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
%
% INPUT
% S: nonscalor structure
% RowOrCol ['row' 'col']: specify if the put each row as a field and
% RowOrCol ['row' 'col' 'input']: specify if the put each row as a field and
% data, or each col as a field and data. Default is 'col'.
%
% EXAMPLE
Expand Down Expand Up @@ -32,6 +32,9 @@
C = horzcat(F, C);
case 'col'
C = vertcat(F', C');
case 'input'
C = vertcat(F', C');
C = C(:)';
otherwise
error('%s: Unrecognized option "%s". Use ''row'' or ''col''.', mfilename, RowOrCol);
end
29 changes: 29 additions & 0 deletions Src/FigureTools/flippedLegend.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
%flippedLegend is a modifier for the Matlab's legend, in which the legends
%are drawn in flipper order to matched stacked bar plots. Simply use
%flippedLegend similar to legend.m

function varargout = flippedLegend(varargin)
[Lx1, Lx2] = legend(varargin{:});

Types = arrayfun(@(x) x.Type, Lx2, 'un', 0);
TextIdx = find(strcmpi(Types, 'text'));
HggIdx = find(strcmpi(Types, 'hggroup'));

%Swap the text positions
AllPos = flipud(vertcat(Lx2(TextIdx).Position));
for j = 1:numel(TextIdx)
Lx2(TextIdx(j)).Position = AllPos(j, :);
end

%Swap the box positions
AllVert = cell(numel(HggIdx), 1);
for j = 1:numel(HggIdx)
AllVert{j} = get(Lx2(HggIdx(j)).Children, 'Vertices');
end
AllVert = flipud(AllVert);
for j = 1:numel(HggIdx)
set(Lx2(HggIdx(j)).Children, 'Vertices', AllVert{j});
end

varargout{1} = Lx1;
varargout{2} = Lx2;
3 changes: 3 additions & 0 deletions Src/FigureTools/setAxes.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
%
function setAxes(varargin)
[Axs, varargin] = getOpenGCA(varargin{:});
if numel(varargin) == 1 && isstruct(varargin{1})
varargin = struct2array(varargin{1}, 'input');
end

for a = 1:length(Axs)
%Modify the Axes handle
Expand Down
1 change: 1 addition & 0 deletions Src/FileIOTools/openSeqData.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
if nargin == 0
FullFileName = getBriliaFiles('', 0, 0);
else
varargin = cleanCommandLineInput(varargin{:});
if contains(varargin{1}, {'.', filesep})
FullFileName = dir2(varargin{1}, 'file');
varargin = varargin(2:end);
Expand Down

0 comments on commit 934499b

Please sign in to comment.