Connecting 2D ellipses in a 3D plot to make a 3D 'tunnel'
3 views (last 30 days)
Show older comments
Thomas Swain
on 29 Feb 2020
Commented: Star Strider
on 29 Feb 2020
Hi all,
I have produced a 3D plot which shows the mean trace of a number of movements. I have also come up with an 'error band' using a number of ellipses (see attached figure).
While this is suitable for the desired application, I think that if I can connect the ellipses and produce a semi-transparent 'tunnel', this would look far better.
The code I used to produce the plot in the figure is as follows:
hold off
plot3(x_mean_origin,y_mean_origin,z_mean_origin,'r','LineWidth',3)
hold on
for i=1:1:100
a=stddevmax_smooth(i);
b=zstddev(i);
x=a*cos(theta)+x_mean_origin(i);
y=zeros(1,numel(x))+y_mean_origin(i);
z=b*sin(theta)+z_mean_origin(i);
rotate(plot3(x,y,z,'m'),[0 0 1],phi(i),[x_mean_origin(i) y_mean_origin(i) z_mean_origin(i)]);
end
I am aware of functions such as 'fill' and 'surf' and 'mesh', but not really sure how to incorporate them in this instance. I'm hoping it is fairly straightforward, so any support you can provide is greatly appreciated! Also I have only supplied a small section of my code, so if any more is required for context, just let me know.
Many thanks!
0 Comments
Accepted Answer
Star Strider
on 29 Feb 2020
I am not certain what you want.
Try this:
F = openfig('Mean throw with 1SD error band.fig');
Ax = findobj(F,'Type','Axes');
D = findobj(F,'Type','line');
Q2 = D(50);
for k = 1:numel(D)
X(k,:) = D(k).XData;
Y(k,:) = D(k).YData;
Z(k,:) = D(k).ZData;
end
figure
hs = surf(X, Y, Z)
set(hs, 'EdgeColor','none', 'FaceAlpha', 0.5)
grid on
producing:
Experiment to get the result you want. See Surface Properties to understand options for surf plots to get it to look the way you want it to look.
2 Comments
More Answers (0)
See Also
Categories
Find more on Graphics Performance 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!