Reputation: 371
I computed the quantiles at 5%, 50% and 95% with the command quantile(x, p). Now I would like to print these values with the boxplot or something that is appealing and clear. I found the boxplot function, but it prints only the 25%, 50% (the mean) and the 95%. Can I print the quantiles as I said before?
Upvotes: 0
Views: 275
Reputation: 1163
A somewhat inelegant solution would be to create the "boxes" yourself.
For example:
% Create the quantile arrays
N = 10; % number of points
x = 1:N;
q5 = rand(N, 1)./10; % 5% quantile
q50 = rand(N, 1); % 50% quantile
q95 = rand(N, 1).*10; % 95% quantile
% Create boxes
figure
hold on
w = 0.2; % width of the boxes
for i = 1:N
plot(x(i) + [-0.5, 0.5].*w, [q5(i), q5(i)], '-b', 'LineWidth', 2) % bottom of box
plot(x(i) + [0.5, 0.5].*w, [q5(i), q95(i)], '-b', 'LineWidth', 2) % right side
plot(x(i) + [-0.5, 0.5].*w, [q95(i), q95(i)], '-b', 'LineWidth', 2) % top of box
plot(x(i) + [-0.5, -0.5].*w, [q95(i), q5(i)], '-b', 'LineWidth', 2) % left side
plot(x(i) + [-0.5, 0.5].*w, [q50(i), q50(i)], '-r', 'LineWidth', 2) % mean
end
Just as simply, you could also add the whiskers.
Upvotes: 1