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

조회 수: 2 (최근 30일)
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.

채택된 답변

Ben11
Ben11 2014년 6월 24일
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);

추가 답변 (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