From 934499bba6676ab0f7bba5047e270dd35849b81b Mon Sep 17 00:00:00 2001 From: dleebhsai Date: Tue, 29 Jan 2019 11:09:57 -0500 Subject: [PATCH] Edited some functionalities. --- Src/CommonTools/struct2array.m | 5 ++++- Src/FigureTools/flippedLegend.m | 29 +++++++++++++++++++++++++++++ Src/FigureTools/setAxes.m | 3 +++ Src/FileIOTools/openSeqData.m | 1 + 4 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 Src/FigureTools/flippedLegend.m diff --git a/Src/CommonTools/struct2array.m b/Src/CommonTools/struct2array.m index 09f04eb..26626ab 100644 --- a/Src/CommonTools/struct2array.m +++ b/Src/CommonTools/struct2array.m @@ -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 @@ -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 \ No newline at end of file diff --git a/Src/FigureTools/flippedLegend.m b/Src/FigureTools/flippedLegend.m new file mode 100644 index 0000000..38a07a2 --- /dev/null +++ b/Src/FigureTools/flippedLegend.m @@ -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; \ No newline at end of file diff --git a/Src/FigureTools/setAxes.m b/Src/FigureTools/setAxes.m index 6ec76e3..a5e2380 100644 --- a/Src/FigureTools/setAxes.m +++ b/Src/FigureTools/setAxes.m @@ -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 diff --git a/Src/FileIOTools/openSeqData.m b/Src/FileIOTools/openSeqData.m index 9dbff01..66b9453 100644 --- a/Src/FileIOTools/openSeqData.m +++ b/Src/FileIOTools/openSeqData.m @@ -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);