projection of 3D plot onto 2D.

3 views (last 30 days)
Dear all,
saved1.png
Dear all,
Above is a 3D plot of a data and a line plot(white). The line plot starts from x=-0.2 and proceeds in a peicewise linear way up. However, as shown above, the lower part of this line is hidden. Possibly overshadowed by the 3D color graph.
My desired output is to show the full shape(or lenght) of the while line above the color map. Below is the code I used for the above plot.
figure(5);
clf
[xx,yy] = meshgrid(gridX,time_t);
HH = mesh(xx,yy,U);
view([0 90])
hold on
%for the white line
plot(xi_t,time_t, 'w', 'linewidth', 1.9);
ylabel('t')
xlabel('x')
colorbar
hold off
How do I solve this problem? Someone help me please. I have looked up and tried suggesstions on how to project a 3D figure onto 2D surface but to no avail.
THanks in advance

Accepted Answer

Star Strider
Star Strider on 6 Oct 2019
You can change the transparency ('FaceAlpha') of the surf plot. The problem is that the line is white, so even with a very low 'FaceAlpha' value, it will not be visible. I would reduce the 'FaceAlpha' value, and make the line a colour that will contrast sufficiently with the surf plot to be visible beneath it.
Experiment with this:
[X,Y] = meshgrid(-1:0.01:1);
Z = X.^3 + sin(Y*2*pi);
figure
HH = surf(X, Y, Z);
HH.FaceAlpha = 0.3;
hold on
plot((1:20)/20, rand(1,20)*2-1, 'r', 'LineWidth',1.9)
hold off
shading('interp')
% view(0, 90)
  2 Comments
Kwame Atta Gyamfi
Kwame Atta Gyamfi on 6 Oct 2019
Thanks it worked. I can see patches of the peicewise line at the bottom if FaceAlpha = 0.8. It appears there's a compromize on the quality of the color map though.
Star Strider
Star Strider on 6 Oct 2019
As always, my pleasure.
There are always trade-offs. Experiment with the colormap and caxis functions to see if it’s possible to get a better result.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!