필터 지우기
필터 지우기

How to plot several confidence intervals together?

조회 수: 3 (최근 30일)
Mahmoud Zeydabadinezhad
Mahmoud Zeydabadinezhad 2018년 2월 13일
댓글: John D'Errico 2018년 2월 16일
Hi, I need to plot three regression lines and their confidence interval, all in one plot. It would be something like the attached plot that is created by SAS.
Any idea how to do this in MATLAB?
Thanks!

채택된 답변

John D'Errico
John D'Errico 2018년 2월 13일
Can you plot ONE regression line with a confidence band around it? Of course. The CI is trivial - basic stats.
You can plot the CI band as a patch. So plot it as a polygon, filled with your choice of color. Patch or fill will work here. Make it semi-transparent, so alpha around 0.2 or so.
Then learn how to plot additional curves on one figure, one set of axes. Thus learn how to use the hold command, to cause MATLAB to plot a second curve (and associated confidence band) onto an existing figure.
All easy. Just read the help and examples for a few functions. Spend some time learning the basic stats if you need that to learn how to compute the CI band.
  댓글 수: 2
Mahmoud Zeydabadinezhad
Mahmoud Zeydabadinezhad 2018년 2월 16일
Hi John, I faced a problem here. The CI band is usually expanding at the ends and narrows in the middle but when I use 'patch' or 'fill' it doesn't do that. Please let me know what you think. I attached two figs to show you what I mean.
Thanks,
John D'Errico
John D'Errico 2018년 2월 16일
Of course it does not fill it. You need to create the CI bands as ONE curve, NOT as two curves. Go up along one bound, then down to the second, and back along the second curve, with the second curve flipped in sequence so you traverse it backwards. The result will be a closed polygonal region. Then tools can be used to fill that region with your desired color.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by