Surf and XLIM YLIM -- setting the limits on a 3D graph doesnt seem to work?
47 views (last 30 days)
Show older comments
Matlab2010 on 14 Feb 2013
I have the following code
set(gca,'xlim',[0 2],'ylim',[0 2]);
Hence I only wish to show the surface between 0 and 2 on the x and y axis.
however, xlim ylim do not seem to work as per normal here. The data is shown overhanging the axis and doesnt look neat and tidy.
what have i done wrong? thank you
Sean de Wolski on 14 Feb 2013
Edited: Sean de Wolski on 14 Feb 2013
Clipping is known to not necessarily work for three-d plots:
With newer versions of MATLAB you can use addlistener to listen to the 'PostSet' limit events on the axes and update the surface's data with new data NaNing out everything outside of the new limits.
Alright, you piqued my interest:
%Clip a three dimensional surface example
% Sean de Wolski 02/14/2013 - MathWorks
ax = axes;
h = surf(xx,yy,zz);
xlimits = get(ax,'XLim');
ylimits = get(ax,'YLim');
%Listen to changes
%When limits change
zzNaN = zz; %copy
xlimits = evt.NewValue;
ylimits = evt.NewValue;
%Clip with Nans
zzNaN(xx<xlimits(1) | xx>xlimits(2)) = NaN;
zzNaN(yy<ylimits(1) | yy>ylimits(2)) = NaN;
More Answers (0)
Find more on Graphics Performance in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!