Mesh plot with only every nth line plotted?
5 views (last 30 days)
Show older comments
Hello,
is it possible to reduce the number of plotted lines in a mesh-plot without loss of accuracy? I know, I can reduce the number of data points. But in this case the accuracy of the mesh-plot gets quite bad (see exsample below). Is there any way to say "mesh" to show only every nth line of the wireframe?
% [Matlab]
[DataX,DataY,DataZ] = peaks(100);
subplot(1,2,1);
mesh(DataX,DataY,DataZ,'EdgeColor','k');
subplot(1,2,2);
mesh(DataX(1:10:end,1:10:end),DataY(1:10:end,1:10:end),...
DataZ(1:10:end,1:10:end),'EdgeColor','k');
% [/Matlab]
Best regards
Guido
[Edit] Really bad mistake in writing corrected. [/Edit]
0 Comments
Accepted Answer
Mike Garrity
on 10 Oct 2014
There isn't a nice automatic way to do it, but it's not too hard. You need 3 surfaces. One for the white background, one for the row edges, and one for the column edges. It would look something like this:
rskip = round(linspace(1,size(DataZ,1),32));
cskip = round(linspace(1,size(DataZ,2),32));
surf(DataX,DataY,DataZ,'FaceColor','white','EdgeColor','none');
hold on
surf(DataX(rskip,:),DataY(rskip,:),DataZ(rskip,:),'FaceColor','none','MeshStyle','row');
surf(DataX(:,cskip),DataY(:,cskip),DataZ(:,cskip),'FaceColor','none','MeshStyle','column');
hold off
The reason for this is that you want to reduce the resolution between edges, but not along edges.
More Answers (1)
Thorsten
on 10 Oct 2014
If you reduce the number of lines the plot will usually be less accurate, unless in special cases where you have, e.g., a plane. The only thing you can do is to find a compromise between accuracy and line number that fits your needs.
See Also
Categories
Find more on Surface and Mesh Plots 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!