How can i use transparency parametr in plot3 or other method to make my plot semi transparency
Show older comments
I want to make my plot3 semi transparency
l1=20;l2=50;l3=40;
t1=linspace(-180,180,45)*pi/180;
t2=linspace(-180,180,45)*pi/180;
t3=linspace(-180,180,45)*pi/180;
[T1,T2,T3]=ndgrid(t1,t2,t3);
xM = round(l2*cos(T1).*cos(T2)+l3*cos(T1).*cos(T2+T3));
yM = round(l2*sin(T1).*cos(T2)+l3*sin(T1).*cos(T2+T3));
zM = round(l1+l2*sin(T2)+l3*sin(T2+T3));
w=plot3(xM(:),yM(:),zM(:),'b.','LineWidth',0.3)
i have try
w.color(4)=0.5
and changing Alpha paremetr but it didnt work
Thanks for your help
Answers (1)
You can play around with some hidden marker properties.
%get marker handles
markers=w.MarkerHandle;
%change transparency by altering 4th element
markers.EdgeColorData=uint8([0 0 255 50])'
edit: You have to add drawnow before those two lines of code
11 Comments
Maciej Zareba
on 28 Jun 2018
jonas
on 28 Jun 2018
What do you mean not working? Is the attached result not what you are looking for?
Maciej Zareba
on 28 Jun 2018
Edited: Maciej Zareba
on 28 Jun 2018
Maciej Zareba
on 28 Jun 2018
jonas
on 28 Jun 2018
Dont know. Maybe someome smarter than me can chime in.
Maciej Zareba
on 28 Jun 2018
jonas
on 28 Jun 2018
No problem. Maybe these will help you
https://se.mathworks.com/matlabcentral/answers/249044-code-fails-to-run-in-function-works-in-command-window-works-in-debug-evaluate-selection
https://se.mathworks.com/matlabcentral/answers/90391-the-command-is-working-perfectly-in-the-command-window-but-not-as-a-script
Maciej Zareba
on 28 Jun 2018
btw, I have updated the answer to fix the previous issue with command not working in script.
I don't have a fix for your most recent issue. If you want to pan/rotate, the transparancy is reset and you must manually update it. If you want to print a specific view, just change the view() in the script before changing the transparency.
Maciej Zareba
on 29 Jun 2018
Categories
Find more on Lighting, Transparency, and Shading 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!