Skip to content

Commit ca780a3

Browse files
committed
allow more lgpdens options
1 parent a48f3b5 commit ca780a3

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

misc/violinplot.m

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,12 @@
2222
% on or off (default)
2323
% cutoff - cutoff for not plotting thin tails. Default is
2424
% 0.01, that is, 1% of the mass in both tails is not plotted
25+
% gridn - optional number of grid points used. Default is 400
26+
% bounded - tells if the density is bounded from left or right
27+
% (default is [0 0]). In unbounded case, decreasing tails
28+
% are assumed.
2529
%
26-
% Copyright (c) 2011 Aki Vehtari
30+
% Copyright (c) 2011,2016 Aki Vehtari
2731

2832
% This software is distributed under the GNU General Public
2933
% License (version 3 or later); please refer to the file
@@ -39,13 +43,17 @@
3943
ip.addParamValue('cutoff',.01, @(x) isreal(x)&& isscalar(x) && x>0 && x<1);
4044
ip.addParamValue('dots', 'off', @(x) islogical(x) || ...
4145
ismember(x,{'on' 'off'}))
46+
ip.addParamValue('gridn',400, @(x) isnumeric(x));
47+
ip.addParamValue('bounded',[0 0], @(x) isnumeric(x) && min(size(x))==1 && max(size(x))==2);
4248
ip.parse(x,varargin{:});
4349
x=ip.Results.x;
4450
y=ip.Results.y;
4551
color=ip.Results.color;
4652
xrange=ip.Results.range;
4753
cutoff=ip.Results.cutoff;
4854
dots=ip.Results.dots;
55+
gridn=ip.Results.gridn;
56+
bounded=ip.Results.bounded;
4957

5058
horiz=true;
5159
if isempty(y)
@@ -60,7 +68,7 @@
6068

6169
[n,m]=size(y);
6270
for i1=1:m
63-
[p,notused,yy]=lgpdens(y(:,i1),'gridn',200,'range',xrange);
71+
[p,notused,yy]=lgpdens(y(:,i1),'gridn',200,'range',xrange,'bounded',bounded,'gridn',gridn);
6472
cp=cumsum(p./sum(p));
6573
qicutofflo=binsgeq(cp,cutoff/2);
6674
qicutoffhi=binsgeq(cp,1-cutoff/2);

0 commit comments

Comments
 (0)