MATLAB: How to plot max, min and average over a histogram

graphMATLABplot

I have the following code that plots me a histogram:
% 1st GRAPH
figure(2)
hold on
a = connected_sites(:,3);
n = histc(a,1:nr_BBU);
max1 = max(n); % Max. valor
min1 = min(n); % Min. valor
avg1 = mean(n); % Valor medio
std1 = std(n); % Desvi. estándar
bar(1:nr_BBU,n)
title('Histogram distribution pool')
plot(1:nr_BBU,max1,'r.' ,'MarkerSize',15) %
set(gca,'XTick',1:nr_BBU)
xlabel('BBU Pool ')
ylabel('Nº of RRHs Connected');
legend({'BBU', 'Max1'},'AutoUpdate','off', 'Location', 'northeast')
And I get the desired histogram with an indicator for maximum values, but I would like to plot over also the minimum values, and the average.
Unfortunately I am quite as plotting is concerned and I can't get it. Any hints? Maybe it would be better to over plot a boxplot indicating the min, max and average??? I also can't get it to work.

Best Answer

(continuing from comment section under the question)
To show the min or mean, substitute those values in for the max value in the line below.
plot(1:nr_BBU, max1, 'r.' , 'MarkerSize', 15) %
% ^^^^ max value
How easy would it be to over plot a boxplot ?
A boxplot isn't what you're looking for. A boxplot shows the quartile ranges, not the max and min. You could, however, use a vertical errorbar.
data = randi(20,1,6);
bar(1:size(data,2), data, 'DisplayName', 'Data')
minData = min(data);
maxData = max(data);
meanData = mean(data);
hold on
errorbar(size(data,2)+1, meanData, meanData-minData, maxData-meanData, '-d', 'Vertical', ...
'LineWidth', 2, 'MarkerSize', 10, 'DisplayName', '[min, mean, max]')
legend()
or horizontal reference lines
data = randi(20,1,6);
bar(1:size(data,2), data, 'DisplayName', 'Data')
minData = min(data);
maxData = max(data);
meanData = mean(data);
yline(minData, 'k-', 'Minimum')
yline(maxData, 'k-', 'Maximum')
yline(meanData, 'k-', 'Mean')
ylim([0, maxData+2])