BillyJean
BillyJean

Reputation: 1587

plot 2D intensity figure in 3D coordinate system

I have a 2D intensity plot, as in this example:

[xx yy] = meshgrid(0:0.1:1, 0:0.1:1);

figure(1)
imagesc(sin(xx)) %(x,y)-plot at z=0

Now, as I have noted in the comment, this plot is in the xy-plane and I have taken z=0. I'd like to plot this in a 3D coordinate system as a function of x and y, but taking z=0. I tried with plot3 in this way, plot3(xx,yy,cos(yy)), but that only plots lines and gives them a curvature which I am not interested in. I'd like only a plane at z=0.

Upvotes: 1

Views: 100

Answers (1)

Suever
Suever

Reputation: 65460

You can use surf to accomplish this. We use the xx and yy meshgrid outputs as the x and y positisions, a matrix of zeros as the z value and sin(xx) as the color. We also remove the edges by setting the EdgeColor to none.

surf(xx, yy, zeros(size(xx)), sin(xx), 'EdgeColor', 'none')

enter image description here

Upvotes: 2

Related Questions