How do I set Transparency of area plot in R2014b?

Hi! I've recently migrated to R2014b and I'm having troubles setting the transparency value of an area plot which worked fine before.
Time = [1:1:10];
y = Time;
recess = [2,0; 2,1; 4,1; 4,0; 6,0; 6,1; 8,1; 8,0]
[AX, LINE1, AREA]= plotyy(Time,y,recess(:,1),recess(:,2),@plot,@area);
%set properties of lines and area
set(LINE1,'Linewidth',2)
set(AREA,'EdgeColor', 'none'); % make area's edge invisible
set(get(AREA, 'Children'), 'FaceAlpha', 0.3); %here is the problem - I cannot use FaceAlpha in the same way as before anymore
Please let me know if you have an idea how to circumvent this problem. I'm grateful for any advice. Thank you!!

답변 (2개)

Jacob D
Jacob D 2015년 8월 28일
편집: Jacob D 2015년 8월 28일

1 개 추천

Here is a solution to your problem. It allows transparent area plots in R2014b and newer. =] I only replaced your last line of code with the last three lines shown here:
Time = [1:1:10];
y = Time;
recess = [2,0; 2,1; 4,1; 4,0; 6,0; 6,1; 8,1; 8,0]
[AX, LINE1, AREA]= plotyy(Time,y,recess(:,1),recess(:,2),@plot,@area);
%set properties of lines and area
set(LINE1,'Linewidth',2)
set(AREA,'EdgeColor', 'none'); % make area's edge invisible
% Make area transparent
drawnow; pause(0.05); % This needs to be done for transparency to work
AREA.Face.ColorType = 'truecoloralpha';
AREA.Face.ColorData(4) = 255 * 0.3; % Your alpha value is the 0.3
Chad Greene
Chad Greene 2014년 12월 27일

0 개 추천

After creating the plot you may be able to use h = findobj('Type','patch'); to get handles of all patch objects, then set facealpha of h.

댓글 수: 4

Julia
Julia 2014년 12월 28일
Hi Chad, thanks for your fast reply. I've tried your suggestion, but findobj(AREA,'Type','patch') just returns a 0x0 empty GraphicsPlaceholder array. Under properties of AREA children = [], so no wonder I can't access FaceAlpha anymore. Is there another way to change the transparency property of an area in R2014b?
Hi Julia, I don't think plotyy is returning correct AREA handles. That's why I suggested using findobj without using AREA as an input to return all visible patch objects. If other patch objects exist you may need to manually determine which handles in h are of interest to you.
Hi Chad, I agree with Julia: findobj no longer works. Probably due to graphics system update in R2014b.
h = findobj('Type','patch')
no longer works. Just like
h = findall(gca,'Type','patch')
.
So.. any luck with looking for answer?
Brandon
Brandon 2015년 3월 11일
This made me sad.

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

카테고리

도움말 센터File Exchange에서 Creating, Deleting, and Querying Graphics Objects에 대해 자세히 알아보기

질문:

2014년 12월 27일

편집:

2015년 8월 28일

Community Treasure Hunt

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

Start Hunting!

Translated by