Mesh plot with only every nth line plotted?

5 ビュー (過去 30 日間)
Guido
Guido 2014 年 10 月 10 日
コメント済み: Guido 2014 年 10 月 10 日
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]

採用された回答

Mike Garrity
Mike Garrity 2014 年 10 月 10 日
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.
  1 件のコメント
Guido
Guido 2014 年 10 月 10 日
Hello Mike,
yes, the trick is the first white surface. I already tried the other steps but I wasn't successful because of the missing white surface. Thank you very much.
% [Matlab]
[DataX,DataY,DataZ] = peaks(100);
subplot(1,2,1);
mesh(DataX,DataY,DataZ,'EdgeColor','k');
subplot(1,2,2);
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');
% [/Matlab]
Best regards
Guido

サインインしてコメントする。

その他の回答 (1 件)

Thorsten
Thorsten 2014 年 10 月 10 日
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.
  1 件のコメント
Guido
Guido 2014 年 10 月 10 日
Hello Thosten,
thank you for your hint.
Best regards
Guido

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by