Use different shading in the same figure

139 views Asked by At

Is it possible to use different shading types in the same figure?

For example this code:

figure; hold on 
surf(1:10,1:10,repmat(1,10,10),rand(10))
shading flat; hold on
surf(1:10,1:10,repmat(3,10,10),rand(10))
shading flat; hold on
surf(1:10,1:10,repmat(5,10,10),rand(10))
shading interp
view(-15,32)

results in: example

So that the last shading determines the type interp for all the objects in the figure.

Is there some work around?

1

There are 1 answers

0
Sardar Usama On BEST ANSWER

By default, 'FaceColor' is flat and 'EdgeColor' is black when you use surf.
shading flat sets the 'FaceColor' as 'flat' and 'EdgeColor' as none.
shading interp sets the 'FaceColor' as 'interp' and 'EdgeColor' as none.

So you can specify those properties like this:

figure;
surf(1:10,1:10,repmat(1,10,10),rand(10),'EdgeColor','none');
hold on;     %You don't need to use hold on again and again
surf(1:10,1:10,repmat(3,10,10),rand(10),'EdgeColor','none');
surf(1:10,1:10,repmat(5,10,10),rand(10),'FaceColor', 'interp','EdgeColor','none');
view(-15,32);

which gives:

output

or get a handle to each surface plot and change that later as shown in the documentation.