I have created a mesh plot, and used the view(2) command to project
the resulting 3D figure into the plane.
I would now like to plot a vertical and horizontal line on top of
this mesh plot.
However, I am having difficulty doing this.
Here is a simple example of what I did:
[X,Y] = meshgrid(-3:.0125:3);
Z = peaks(X,Y);
meshc(X,Y,Z);
axis([-3 3 -3 3 -10 5])
view(2);
hold on;
plot([2.5,2.5],[-3;3],'k'); % vertical line
plot([-3;3],[-1;-1],'k'); % horizontal line
For this example, both the vertical and horizontal lines show up
partially, but not completely.
The vertical line shows up from y = -3 to about y = -2.
The horizontal line shows up from x = -3 to about x = -1.6 and then
again from about x = -0.1 to about x = 1.2.
For some of the mesh plots I have drawn, the horizontal and vertical
lines do not show up at all.
Is there a way to treat the mesh plot as a 'background' object in the
figure, and place lines on top, so that they are completely viewable?
Thanks for your help.
Michael
one solution :
[X,Y] = meshgrid(-3:.0125:3);
Z = peaks(X,Y);
meshc(X,Y,Z);
axis([-3 3 -3 3 -10 5])
view(2);
hold on;
mZ=max(Z(:))+1;
line([2.5 2.5],[-3 3],[mZ mZ],'color','k'); % vertical line
line([-3 3],[-1 -1],[mZ mZ],'color','k'); % horizontal line
Jérôme
[X,Y] = meshgrid(-3:.0125:3);
Z = peaks(X,Y);
meshc(X,Y,Z);
axis([-3 3 -3 3 -10 5])
view(2);
hold on;
line([2.5 -3 ; 2.5 3],...
[-3 -1 ; 3 -1],...
repmat(max(Z(:))+1,2,2),...
'color','k');
Jérôme