krm76
krm76

Reputation: 356

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

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.

plot obtained

Unfortunately I am quite new as plotting is concerned in matlab 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.

Upvotes: 0

Views: 502

Answers (1)

krm76
krm76

Reputation: 356

figure('Name', 'RRH histogram distribution over BBU')
a = connected_sites(:,3);
n = histc(a,1:nr_BBU); % Calcula la frecuencia de la columna de BBU-conectada
minData = min(n); 
maxData = max(n); 
meanData = mean(n); 

yline(minData, 'r-', 'Minimum')
yline(maxData, 'r-', 'Maximum')
yline(meanData,'r-', 'Mean')
ylim([0, maxData+2])

hold on
bar(1:nr_BBU,n)
title('BBU pools')
set(gca,'XTick',1:nr_BBU) % Para poner el eje X completo con todos los valores
xlabel('BBU Pool ')
ylabel('Nº of RRHs Connected');

Upvotes: 2

Related Questions