for some reason i want to set the zdata of a surface plot object to zero, keeping its color, and setting view point to [0 0 1] (looking at it from the top).
code used:
surfobjhandle=surf(X,Y,Z); colordata=get(surfobjhandle,'cdata'); view([0 0 1]); set(surfobjhandle,'zdata',zeros(size(get(surfobjhandle,'zdata')))); set(surfobjhandle,'cdata',colordata);
however, this way the surface is not visible anymore with the viewpoint set to [0 0 1]. it only appears setting a different viewpoint which is not what i want. why is this?
No products are associated with this question.
This example is probably equivalent to what you want:
[X,Y,Z]=peaks(25); figure; surf(X,Y,zeros(size(Z)),Z) ; view(3); axis vis3d;
Perhaps you loose your plot because of axis tight? That sometimes crops too tightly. Also have a look at using the pcolor and imagesc commands instead.
Kevin
4 Comments
Direct link to this comment:
http://www.mathworks.co.uk/matlabcentral/answers/45571#comment_95190
Please provide some values for X, Y and Z, which allows to reproduce the problem.
Direct link to this comment:
http://www.mathworks.co.uk/matlabcentral/answers/45571#comment_96578
Most likely a rendering problem. Try running
before running your code. Or manually change the renderer to painters or zbuffer.
Direct link to this comment:
http://www.mathworks.co.uk/matlabcentral/answers/45571#comment_96579
i'm puzzled: it's almost 3 weeks after i posted the question and i'm not able to reproduce the problem anymore... the code i posted works just fine now.
Direct link to this comment:
http://www.mathworks.co.uk/matlabcentral/answers/45571#comment_96580
@Peter: If you had posted the test data I've asked for, the problem would have been solved faster, perhaps.