Often if you make a surface plot with SURF for a large dataset, it will appear all black because MATLAB is trying to draw all the edge lines. You can stop these lines from obscuring your data by turning the edge color off:
a= peaks(1000);
h = surf(a)
set(h, ‘edgecolor’,'none’)
I often want the high shape resolution given by large data sets for a surface, but also want to see the net over the surface. This is useful for publication/presentation purposes. Since, as you show, using the net as is will make the whole surface black, I modify it by doing something like this:
a = peaks(1000);
opengl software
h = surf(a);
set(h, 'edgecolor','none')
hold on
x = 1:1000;
k = [1 0:20:1000]; % The values to keep.
k(2) = [];
st = setxor(x,k);
x(st) = NaN; % Set most values so they won't plot.
[xx,yy] = meshgrid(x);
idx1 = isnan(xx)|isnan(yy);
a(idx1) = NaN;
idx2 = ~isnan(xx)&~isnan(yy);
xx = reshape(xx(idx2),51,51); % Reshape these guys.
yy = reshape(yy(idx2),51,51);
aa = reshape(a(idx2),51,51);
m = mesh(xx,yy,aa+.04); % Create the net.
set(m,'edgecolor','black','facealpha',0,'linewidth',1)
set(1,'units','normalized','position',[.05 .05 .85 .85])
Note that I added a small value to the aa matrix. This is because if left alone the net will have patches that are blocked by the surface, mainly at the peaks. Of course it makes the underside of the surface look worse in this regard, but as I said, I use this technique to get a static image for publication/presentation purposes.
Leave a Reply
About
Bob, Brett & Jiro share their favorite user-contributed submissions from the File Exchange.
Hi Doug.
Personally I tend to use the
commands. They take care of greater number of objects automatically, but internally use similar commands you presented in the video.
Regards, Petr
I often want the high shape resolution given by large data sets for a surface, but also want to see the net over the surface. This is useful for publication/presentation purposes. Since, as you show, using the net as is will make the whole surface black, I modify it by doing something like this:
Note that I added a small value to the aa matrix. This is because if left alone the net will have patches that are blocked by the surface, mainly at the peaks. Of course it makes the underside of the surface look worse in this regard, but as I said, I use this technique to get a static image for publication/presentation purposes.