MATLAB Answers

Translated by

このページのコンテンツは英語から自動翻訳されています。自動翻訳をオフにする場合は「<a class="turn_off_mt" href="#">ここ</a>」をクリックしてください。

0

Indicating statistical significance on boxplot in matlab

Hari krishnan さんによって質問されました 2018 年 10 月 28 日
最新アクティビティ jonas
さんによって コメントされました 2018 年 10 月 28 日
I am plotting two boxplots with my sample data sets in matlab. I wanted to put a star sign between the boxplots indicating the statistical significance. When i draw this star, its adjusted to one corner rather than between the boxes. I am attaching the boxplot with this. Any help to solve this will be appreciated.
x1 = required_data_threhold_time_for_recruitment_gdnest;
x2 = required_data_threhold_time_for_recruitment_bdnest;
x = [x1 ;x2];
g = [ones(size(x1)); 2*ones(size(x2))];
boxplot(x,g,'Labels',{'Good nest (1 lux)','Poor nest (16 lux)'});
ylabel('Time(seconds)')
yt = get(gca, 'YTick');
axis([xlim 0 ceil(max(yt)*1.2)])
set(gca, 'Xtick', 1:3);
xt = get(gca, 'XTick');
hold on
plot(xt([2 3]), [1 1]*max(yt)*1.1, '-k', mean(xt([2 3])), max(yt)*1.15, '*k')
hold off

  0 件のコメント

サインイン to comment.

タグ

1 件の回答

回答者: jonas
2018 年 10 月 28 日
編集済み: jonas
2018 年 10 月 28 日
 採用された回答

It is exactly where you plotted it, why would you expect a different result?
plot(mean(xt([2 3])), max(yt)*1.15, '*k')
so at x=2.5 (as xt = [1 2 3]) and a little bit above the maximum value of yt, which I can only assume to be 5000 (the max ytick was probably 5000 when you created yt).
The reason you are confused is probably because you are using the xticks for determining the location of the plot. What is more confusing is that your xticks extent beyond the axis limits. Basically you have a very simple problem that you try to solve in a very difficult way by involving x- and y-ticks.
If you want it between the boxes, then I can only assume that you should change to:
plot(mean(xt([1 2])), max(yt)*1.15, '*k')
...there are however a lot of assumptions going into this answer, so you may want to clarify.

  2 件のコメント

It worked. I got confused of using xticks. Can i ask a follow up question. If i need to get the P value, for the level of significance, how should i proceed?
jonas
2018 年 10 月 28 日
There are many ways to calculate the P-value and the most appropriate method depends on the nature of your data. To be honest I'm probably not the right person to ask. The few times I have calculated P-values I have used the monte carlo method, mainly because it is intuitively easy to understand and lacks assumptions.

サインイン to comment.



Translated by