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

12 ビュー (過去 30 日間)
carlos ruiz de mendoza
carlos ruiz de mendoza 2020 年 3 月 8 日
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.
  2 件のコメント
Adam Danz
Adam Danz 2020 年 3 月 8 日
Hint:
Repeat this line but substitude the min and mean values for the max value within the line.
plot(1:nr_BBU, max1, 'r.' , 'MarkerSize', 15) %
% ^^^^ max value
carlos ruiz de mendoza
carlos ruiz de mendoza 2020 年 3 月 8 日
Thank you so much!!! How easy would it be to over plot a boxplot ?

サインインしてコメントする。

採用された回答

Adam Danz
Adam Danz 2020 年 3 月 8 日
編集済み: Adam Danz 2020 年 3 月 8 日
(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])
  1 件のコメント
carlos ruiz de mendoza
carlos ruiz de mendoza 2020 年 3 月 9 日
Your proposals are perfect!!!!!! Thank you so much.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeHistograms についてさらに検索

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by