Question

Introduction

I'm trying to emphase some region on a spherical surface saying that this region should be colored as not transparent (alpha = 1.0) and other parts of the sphere should be colored as semi-transparent (alpha = 0.5).

Problem

Considering WAlpha(Data >= DummyValue) = 1.0 and WAlpha(Data < DummyValue) = 0.5, the following command does not work as expected:

surf(X, Y, Z, Data, 'AlphaData', WAlpha, 'FaceAlpha', 'interp');

It draws all non-selected region as fully-transparent:

Wrong transparency

Note

I have no issue when setting 'FaceAlpha' to scalar value (i.e its not an issue with my graphic card):

surf(X, Y, Z, Data, 'AlphaData', WAlpha, 'FaceAlpha', 0.5);

Semi transparent everywhere

Source code

Here is the link to the very short and dummy code I created to reproduce the issue: link

Please let me know if you have any other idea for emphasing selected region rather than using transparency.

Était-ce utile?

La solution

Here is quick test:

%# surface data
Z = membrane;

%# alpha-transparency matrix
A = ones(size(Z))*0.3;          %# transparent by default
A(abs(Z)>0.5) = 1;              %# make certain region opaque

%# plot
figure('Renderer','opengl')
surf(Z, 'AlphaData',A, 'AlphaDataMapping','none', ...
    'FaceAlpha','interp', 'EdgeColor','none')

Result:

screenshot

Autres conseils

Ooops, found it...

One needs to change the Alim property on axes object because it is improperly set to [min(WAlpha) max(WAlpha)] when setting AlphaData instead of keeping [0 1]. So the command is:

surf(X, Y, Z, Data, 'AlphaData', WAlpha, 'FaceAlpha', 'interp');
alim([0 1]);
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top