-
Notifications
You must be signed in to change notification settings - Fork 0
/
stats_visualizing_boxWhisker.m
45 lines (31 loc) · 1.04 KB
/
stats_visualizing_boxWhisker.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
%%
% COURSE: Master statistics and machine learning: intuition, math, code
% URL: udemy.com/course/statsml_x/?couponCode=202112
%
% SECTION: Visualizing data
% VIDEO: Box-and-whisker plots
%
% TEACHER: Mike X Cohen, sincxpress.com
%
%%
% a clear MATLAB workspace is a clear mental workspace
close all; clear
%% create data for the plot
% data sizes
m = 30; % rows
n = 6; % columns
% generate data
data = bsxfun(@times,30*randn(m,n),linspace(-1,1,n).^2);
data = bsxfun(@plus,data,(1:n).^2);
%% show it!
figure(1), clf
boxplot(data)
boxplot(data,{'one';'two';'three';'four';'five';'six'})
%% alternative: data in a single column, grouped by a separate variable
dataVect = data(:);
dataGrouping = ceil(linspace(eps,n,m*n));
figure(2), clf
boxplot(dataVect,dataGrouping,'notch','on','labels',{'one';'two';'three';'four';'five';'six'})
% for horizontal orientation
%boxplot(dataVect,dataGrouping,'notch','on','labels',{'one';'two';'three';'four';'five';'six'},'orientation','horizontal')
%% done.