Cannot plot additional scatter points in a boxplot
2 ビュー (過去 30 日間)
古いコメントを表示
Hello all,
I've got 15 horizontaly orientated boxplots in the same graph with 15 column vectors (x1, x2... x15) each with a different length.
I want to draw two scatter points at y=2 (the points are (x=0.4, y=2.0) and (x=0.6, y=2.0) above the last boxplot which is located at y=1.6.
However I cannot plot those two points and I do know that the command 'hold on' restricts the limits of the boxplots.
*********************************************************************
My code unitl now looks like:
Ypos = [0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.5 1.6];
-----------
group_fordata = [repmat(Ypos(1),[size(x1),1]); repmat(Ypos(2),[size(x2)],1); repmat(Ypos(3),[size(x3)],1); repmat(Ypos(4),[size(x4)],1); repmat(Ypos(5),[size(x5)],1); repmat(Ypos(6),[size(x6)],1); repmat(Ypos(7),[size(x7)],1); repmat(Ypos(8),[size(x8)],1); repmat(Ypos(9),[size(x9)],1); repmat(Ypos(10),[size(x10)],1); repmat(Ypos(11),[size(x11)],1); repmat(Ypos(12),[size(x12)],1); repmat(Ypos(13),[size(x13)],1); repmat(Ypos(14),[size(x14)],1); repmat(Ypos(15),[size(x15)],1)];
-------------
data = [x1;x2;x3;x4;x5;x6;x7;x8;x9;x1;x11;x12;x13;x14;x15]
----------
figure
boxplot(data, group_fordata,'positions', Ypos,'orientation','horizontal')
hold on
plot([0.4 0.6],[2.0 2.0],'g.')
*************************************************************
I cannot see the two points in green plotted. Any alternative to 'hold on' that would allow me to plot something above the value 1.6 of the y-axis?
Many thanks!
0 件のコメント
採用された回答
Mike Garrity
2015 年 5 月 29 日
I think it's just that boxplot leaves the YLim in manual mode. Try this:
ylim auto
3 件のコメント
Mike Garrity
2015 年 5 月 29 日
I don't think that there's a simple shortcut for that, so you're going to need to learn about the Axes object and its properties.
You can get the Axes object using the function "gca". You'll see a bunch of properties on it that you already recognize, such as YLim, but there are lots more:
get(gca)
The one you want is named YTick.
set(gca,'YTick',0:.25:2)
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Discrete Data Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!