Skip to content

Commit

Permalink
Update violinplot.m
Browse files Browse the repository at this point in the history
Updated the vararg parsing.
Not sure it's ended upsimpler but it is a bit more robust
  • Loading branch information
seamusholden committed Jul 17, 2019
1 parent 338429e commit 53c76d0
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions violinplot.m
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,21 @@
% This code is released under the terms of the BSD 3-clause license

hascategories = exist('cats','var') && not(isempty(cats));

%parse the optional grouporder argument
%if it exists parse the categories order
% but also delete it from the arguments passed to Violin
grouporder = {};
ii=1;
while ii<=numel(varargin)
if strcmp(varargin{ii},'GroupOrder')
grouporder = varargin{ii+1};
varargin(ii:ii+1)=[];
ii=ii+2;
idx=find(strcmp(varargin, 'GroupOrder'));
if ~isempty(idx) && numel(varargin)>idx
if iscell(varargin{idx+1})
grouporder = varargin{idx+1};
varargin(idx:idx+1)=[];
else
ii=ii+1;
error('Second argument of ''GroupOrder'' optional arg must be a cell of category names')
end
end


% tabular data
if isa(data, 'dataset') || isstruct(data) || istable(data)
if isa(data, 'dataset')
Expand Down

0 comments on commit 53c76d0

Please sign in to comment.