- each line on your plot not named data, but the legend itself has the value of the mean/std of the line
Histogram: put mean and std in the legend
9 ビュー (過去 30 日間)
古いコメントを表示
In the code below I will have histograms of three series. I want to have mean and std of three series calculated and displayed in the legend of each series. Please advise.
w=0:0.05:1;
ncount1 = histc(x(:,1),w);
relativefreq1=ncount1/NSamples;
ncount2 = histc(x(:,2),w);
relativefreq2=ncount2/NSamples;
ncount3 = histc(x(:,3),w);
relativefreq3=ncount3/NSamples;
figure (4)
plot(w, relativefreq1)
hold on
plot(w, relativefreq2,'LineWidth',1.0)
hold on
plot(w, relativefreq3,'LineWidth',1.5)
legend('Data1','Data2','Data')
title('Distribution of Data')
xlabel('Data')
ylabel('Frequency')
xlim([min(w) max(w)])
set(gca, 'xtick', w)
0 件のコメント
回答 (1 件)
Gareth
2018 年 11 月 20 日
I am using R2018b and my understanding is that you want to have:
If this is the case maybe this example might help you:
data = rand(10,3); %as the data here is not relevant to your question
plot(data);
mymean = mean(data);
mystd = std(data);
% Create Legend
mylegend = "std: " + string(mystd) + " mean: " + string(mymean);
%add to plot
legend(mylegend);
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Data Distribution Plots についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!