Commit 757c1f2d authored by Tom Marshall's avatar Tom Marshall

added option to turn boxplot off

parent ac148f60
......@@ -11,12 +11,16 @@
% Thanks to Jacob Bellmund for some improvements
function h = raincloud_plot(X, cl, density_type)
function h = raincloud_plot(X, cl, density_type, box_on)
if ~exist('density_type', 'var')
if ~exist('density_type', 'var') | isempty(density_type)
density_type = 'ks'; % default is 'ks', can also be 'rash'
end
if nargin < 4
box_on = 1;
end
% calculate kernel density
switch density_type
case 'ks'
......@@ -55,16 +59,17 @@ h{2}.SizeData = 10;
h{2}.MarkerFaceColor = cl;
h{2}.MarkerEdgeColor = 'none';
% 'box' of 'boxplot'
h{3} = rectangle('Position', [Y(1) -yl(2)/2-(wdth*0.5) Y(2)-Y(1) wdth]);
set(h{3}, 'EdgeColor', 'k')
set(h{3}, 'LineWidth', 2);
% could also set 'FaceColor' here as Micah does, but I prefer without
% mean line
h{4} = line([Y(3) Y(3)], [-yl(2)/2-(wdth*0.5) -yl(2)/2+(wdth*0.5)], 'col', 'k', 'LineWidth', 2);
% whiskers
h{5} = line([Y(2) Y(5)], [-yl(2)/2 -yl(2)/2], 'col', 'k', 'LineWidth', 2);
h{6} = line([Y(1) Y(4)], [-yl(2)/2 -yl(2)/2], 'col', 'k', 'LineWidth', 2);
if box_on
% 'box' of 'boxplot'
h{3} = rectangle('Position', [Y(1) -yl(2)/2-(wdth*0.5) Y(2)-Y(1) wdth]);
set(h{3}, 'EdgeColor', 'k')
set(h{3}, 'LineWidth', 2);
% could also set 'FaceColor' here as Micah does, but I prefer without
% mean line
h{4} = line([Y(3) Y(3)], [-yl(2)/2-(wdth*0.5) -yl(2)/2+(wdth*0.5)], 'col', 'k', 'LineWidth', 2);
% whiskers
h{5} = line([Y(2) Y(5)], [-yl(2)/2 -yl(2)/2], 'col', 'k', 'LineWidth', 2);
h{6} = line([Y(1) Y(4)], [-yl(2)/2 -yl(2)/2], 'col', 'k', 'LineWidth', 2);
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment