Reputation: 571
I get the following graph when I run
x1=0:0.01:1;
y1=0:0.01:1;
[X,Y]=meshgrid(x1,y1);
Z=0.8.*X+0.2.*Y;
surf(X,Y,Z);
And when I separately run this code
[X1,Y1]=meshgrid(a,b);
Z1=0.8.*X1+0.2.*Y1;
surf(X1,Y1,Z1,'EdgeColor','none');
I get the following
Here a,b are subsets of x1 and y1.
But what I want is I want to draw the second graph on top of the first surface graph. I used hold on, and used the code,
x1=0:0.01:1;
y1=0:0.01:1;
[X,Y]=meshgrid(x1,y1);
Z=0.8.*X+0.2.*Y;
surf(X,Y,Z);
hold on;
[X1,Y1]=meshgrid(a,b);
Z1=0.8.*X1+0.2.*Y1;
surf(X1,Y1,Z1,'EdgeColor','none');
this is what I get
Why can't I see the second graph on top of this?
Upvotes: 0
Views: 1464
Reputation: 12214
The colors of the surface generated by surf
with this syntax are driven by their Z
values. If you want coplanar surfaces to be visually separated you will need to adjust the FaceColor
of one of the plots.
For example:
x1=0:0.01:1;
y1=0:0.01:1;
[X,Y]=meshgrid(x1,y1);
Z=0.8.*X+0.2.*Y;
s1 = surf(X,Y,Z);
a = x1(40:70);
b = y1(40:70);
hold on;
[X1,Y1]=meshgrid(a,b);
Z1=0.8.*X1+0.2.*Y1;
s2 = surf(X1,Y1,Z1, 'FaceColor', 'r', 'EdgeColor','none');
Gives us the following:
Upvotes: 1