Hi, I would like to draw two area graphs in one plot to overlay each other and have transparent colors. but the area plot library in my Matlab 2014b doesn't have faceAlpha properties.

 채택된 답변

Star Strider
Star Strider 2016년 3월 11일

0 개 추천

I would use the patch function instead. According to the R2014b documentation for Patch Properties, the patch function does have a 'FaceAlpha' option in the name-value pairs. I will help if you need to re-write your code to make it work with patch.

댓글 수: 4

Elaheh Soltanaghaei
Elaheh Soltanaghaei 2016년 3월 11일
Thank you for your reply. However, the output of patch function is different with the area. Here is the an example to compare patch and area function for one of my data groups. Basically, I need the area one with one more graph overlay the first one with transparency to see the overlapped areas.
Area Graph:
Patch graph:
The problem with patch can be fixed, likely easily. The patch function needs to have its areas carefully defined, and sometimes this requires a bit of extra coding. I can help if you attach your data and say what you want to do.
As an interim fix, in the patch call, see if setting both the first and last values of your dependent variable to zero (appending zeros to both ends of the vector) and duplicating the first and last values of your independent variable (the vectors have to be the same lengths) works.
For example:
x = 1:10;
y = [1 2 3 4 5 4 3 0 1 2];
figure(1)
patch(x, y, 'b')
figure(2)
patch([1 x 10], [0 y 0], 'r')
Run this. You will see the difference.
Elaheh Soltanaghaei
Elaheh Soltanaghaei 2016년 3월 11일
Great. It finally works. Thank you very much for your helps :-)
Star Strider
Star Strider 2016년 3월 11일
My pleasure!

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

추가 답변 (1개)

Mike Garrity
Mike Garrity 2016년 3월 11일

1 개 추천

FaceAlpha was added to area in R2015b. So if you upgrade to either that or R2016a, you can do this:
area(rand(1,10),'FaceAlpha',.5)

카테고리

질문:

2016년 3월 11일

댓글:

2016년 3월 11일

Community Treasure Hunt

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

Start Hunting!

Translated by