Plot 3D line object with alpha gradient

7 vues (au cours des 30 derniers jours)
Filip Persson
Filip Persson le 7 Fév 2012
Modifié(e) : Jeremy le 4 Oct 2013
Dear all,
I have a 3D point set which I would like to plot as connected line segments. In addition, I would like the points (lines) furthest away (from the point of perspective) to appear more distant by having an alpha gradient, i.e points closer to the viewer should have higher alpha values than those further away (like looking in a fog).
I tried using
mfig=patch(p(:,1),p(:,2),p(:,3));
set(mfig,'facealpha',0);
set(mfig,'edgealpha',...
and then play with the different alphamappings but unfortunately I don't get it to work.
Does anyone know how to do this (if possible)?
Thanks!
Cheers, Filip

Réponse acceptée

Jonathan Sullivan
Jonathan Sullivan le 7 Fév 2012
amap = linspace(1,0,size(p,1))';
set(mfig,'FaceColor','none','EdgeColor','flat',...
'LineWidth',3,'FaceVertexAlphaData',amap,...
'EdgeAlpha','interp');
  3 commentaires
Walter Roberson
Walter Roberson le 7 Fév 2012
Try adding
'FaceVertexCData', ones(size(amap))
Filip Persson
Filip Persson le 8 Fév 2012
It works!
Thanks to Jonathan and Walter!

Connectez-vous pour commenter.

Plus de réponses (1)

Filip Persson
Filip Persson le 8 Fév 2012
The working script:
amap = linspace(1,0,233)';
mfig=patch(p(:,1),p(:,2),p(:,3),'red');
set(mfig,'facealpha',0);
set(mfig,'FaceColor','none','EdgeColor','flat',...
'LineWidth',3,'FaceVertexAlphaData',amap,...
'EdgeAlpha','interp',...
'FaceVertexCData', ones(size(amap)));

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by