plotting confidence interval and creating second axis in one plot
이전 댓글 표시
I would like to plot two means with their 95% confidence interval around each mean, plus the mean difference including confidence interval in the same plot but on a second axis on the right starting with 0 on the same level as the smaller mean value of the first two means. I came so far as to make the confidence intervals with the errorbar function but cannot figure out how to set a second axis and adjust it to start at the height of the one mean.
I attached a file with an example of how the plot should look like at the end. Thanks for any help!
plot([0 1 2 3],[0,mean_pre2,mean_post1,0],'bo')
hold on
plot([4 5],[mean_diff, 0],'ro')
U = [0,CIpre2_up,CIpost1_up,0,CIdiff_up,0];
L = [0,CIpre2_lo,CIpost1_lo,0,CIdiff_lo,0];
errorbar((0:5),[0,mean(maxAnklePower_pre2),mean(maxAnklePower_post1),0,mean(maxAnklePower_pre2-maxAnklePower_post1), 0],L,U,'o')
댓글 수: 5
Bjorn Gustavsson
2021년 9월 1일
Have a look at the help and documentation for plotyy - it is a bit cludgy when it comes to which axes are the current one after the call, but should be the function you look for.
Bjorn Gustavsson
2021년 9월 2일
@Adam Danz, thanks to you Adam I learnt something today (to people saying that I'm a slow learner, I say "PHU!" - this was only 5-6 years...)
Adam Danz
2021년 9월 2일
Ha! I'd say you're a quick learner. You just discovered yyaxis and you were already able to address the OP's follow-up comment below my answer.
I frequently learn of long existing functions that I should have been using. The accumulation with every release is getting harder to keep up with.
Bjorn Gustavsson
2021년 9월 2일
@Adam Danz - this is especially so for problems where one has a "kind of working solution" - then it is not as urgent to keep track of the newer better solutions...
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
