Setting 'FaceAlpha'<1 for a patch object causes x- and y- axes of the plot to dissapear. Why and how can this be corrected?

1 view (last 30 days)
Hello everyone,
have any of you ever plotted a 2D patch object and noticed that upon altering its 'FaceAlpha' value below 1, it causes the x- and y-axes of the plot to disappear? Just to clarify, by x- and y- axes I mean the horizontal and vertical lines of the plot, respectively, not the axes object where the patch is plotted.
Here is an example of what I talking about:
% Plot a simple patch object
x=[0 1 1 0 0];
y=[0 0 1 1 0];
figure('color','w')
ha1=subplot(1,2,1);
ha2=subplot(1,2,2)
h=fill(x,y,'g');
% DO the same as above, but alter the FaceAlpha value of the patch
figure('color','w')
ha1=subplot(1,2,1);
ha2=subplot(1,2,2);
h=fill(x,y,'g');
set(h,'FaceAlpha',0.5)
Note that changing the transparency of the patch in the second figure caused the x- and y- axes (i.e., horizontal and vertical lines) to disappear in ha1 and ha2.
Does anyone know why this happens, and how can it be corrected?
Thank you!
PS - Not sure if its relevant, but I am using R2013a version of Matlab.

Accepted Answer

Ben11
Ben11 on 24 Jun 2014
I changed your code a bit and set the linewidth property to 1.5 (actually any value larger than 1.5 worked) and it seems to be ok. Honestly I tried many things and this works althought I don't really know why. Anyhow here is the code:
% Plot a simple patch object
x=[0 1 1 0];
y=[0 0 1 1];
hfig1 = figure('color','w');
ha1=subplot(1,2,1);
ha2=subplot(1,2,2);
hfill1 = fill(x,y,'g');
hfig2 = figure('color','w');
ha3=subplot(1,2,1);
ha4=subplot(1,2,2);
hpatchobj = patch(x,y,'g','FaceAlpha',0.5);
set(ha3,'LineWidth',1.5);

More Answers (0)

Categories

Find more on Graphics Performance in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!