File Exchange

image thumbnail

simple box whiskers plot (for those who don't have the statistics toolbox)

version 1.0.0.0 (744 Bytes) by Shane Lin
box whiskers plot, adjustable size and line thickness

5 Downloads

Updated 24 May 2007

No License

* If you have the statistics toolbox, please don't use this one.
* If you are not so lucky, come on and download it freely. This is a very simple version but better than none.
* If you have time to implement more features, give me a copy!

Features:
1/ adjustable box size and adjustable line thickness.
2/ The matlab function is used to compute all median values.
3/ No color support.

Download it and I would like to share my wish with you:
I wish the boxplot.m would be a general matlab function in their next version so I can get rid of the simple version.

Cite As

Shane Lin (2020). simple box whiskers plot (for those who don't have the statistics toolbox) (https://www.mathworks.com/matlabcentral/fileexchange/15053-simple-box-whiskers-plot-for-those-who-don-t-have-the-statistics-toolbox), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (10)

Samuel Kamphof

Thanks a lot for this useful and cost saving tool. This makes MATLAB more interessting and should really be a standard tool for matlab. I was surprised not to find it as a normal tool. Coloring like Valery wrote is nice!

Bradford

Karl

Thanks Rebecca for your improving. I have found one little writing error in your update:
q2(i)=median(data(1:mi,i));

so the corrected script is:
for i=1:n
ni=find(isnan(data(:,i)));
if ni
mi=ni(1)-1;
q2(i)=median(data(1:mi,i));
if(rem(mi,2) == 0)
upperA = data(1:mi/2,i);
lowA = data(mi/2+1:mi,i);
else
upperA = data(1:round(mi/2), i);
lowA = data(round(mi/2):mi, i);
end;

q1(i) = median(upperA, 1);
q3(i) = median(lowA, 1);

min_v(i) = data(1,i);
max_v(i) = data(mi,i);
end
end

Kind regards
Karl

Karl

Thanks a lot! Your box plot saves me a lot of work.
To add names to the single box plots I have adjust some lines and add some parameter:
Line 77-81:
ylabel(yAxisLabel);
set(gca,'XTick',1:n);
set(gca,'XTickLabel',boxNames);
return;

Now you have to change the function head in following way:

function drawBox(draw_data, lineWidth, width, boxNames, yAxisLabel)

function boxPlot(data0, lineWidth, width boxNames,yAxisLabel)

drawBox(draw_data, lineWidth, width, boxNames,yAxisLabel);

Example for calling:

a = [120 250 210]; %1st box
b = [180 200 110]; %2nd box

boxPlot([a' b'],1,1,{'1st box', '2nd box'},'seconds');

Valery

Thanks a lot! Simple and easy. You can modify the line 69 to:
plot([i-unit, i+unit], [v(3), v(3)],'r', 'LineWidth', lineWidth);
so that the median appears in red.

Rebecca

This is great but it only works if all of the data arrays are the same size. If not, you can fill in the shorter arrays with NaN's and add this in at line 42 of the code:

for i=1:n
ni=find(isnan(data(:,i)));
if ni
mi=ni(1)-1;
q2(i)=median(data(i:mi,i));
if(rem(mi,2) == 0)
upperA = data(1:mi/2,i);
lowA = data(mi/2+1:mi,i);
else
upperA = data(1:round(mi/2), i);
lowA = data(round(mi/2):mi, i);
end;

q1(i) = median(upperA, 1);
q3(i) = median(lowA, 1);

min_v(i) = data(1,i);
max_v(i) = data(mi,i);
end
end

Robert Talbert

Thanks VERY much for taking the time to put this up. Nice and simple and free.

Sven Mensing

It is free. Build-in comes with statistics toolbox

Colin Clarke

How is this better than built in boxplot?

MATLAB Release Compatibility
Created with R14
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!