How do I set Transparency of area plot in R2014b?

4 Ansichten (letzte 30 Tage)
Julia
Julia am 27 Dez. 2014
Bearbeitet: Jacob D am 28 Aug. 2015
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!!

Antworten (2)

Jacob D
Jacob D am 28 Aug. 2015
Bearbeitet: Jacob D am 28 Aug. 2015
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 am 27 Dez. 2014
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 Kommentare
Igor
Igor am 6 Feb. 2015
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 am 11 Mär. 2015
This made me sad.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Graphics Performance finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by