4

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.

JasonMArcher
  • 14,195
  • 22
  • 56
  • 52
CitizenInsane
  • 4,755
  • 1
  • 25
  • 56

2 Answers2

3

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

Amro
  • 123,847
  • 25
  • 243
  • 454
  • 1
    Yep, guess setting `AlphaDataMapping` to `none` or resetting `Alim` to `[0 1]` ends up the same. Thanks for your help and test case. – CitizenInsane Jul 20 '12 at 15:22
1

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]);
CitizenInsane
  • 4,755
  • 1
  • 25
  • 56