フィルターのクリア

Add contours to scatter3 plot

5 ビュー (過去 30 日間)
Alex Kurek
Alex Kurek 2017 年 9 月 16 日
編集済み: Alex Kurek 2017 年 9 月 19 日
Hi,
Is there a way to add contours on the walls of this kind of plot? The points are projected onto the walls.
x = mvnrnd(1, 3, 100);
y = mvnrnd(2, 3, 100);
z = mvnrnd(3, 3, 100);
scatter3 (x, y, z, 'filled')
hold on
scatter3 (0*x+ max(x), y, z, '.')
hold on
scatter3 (x, 0*y+max(y), z, '.')
hold on
scatter3 (x, y, 0*z+min(z), '.')
hold off
rotate3d on
Best regards, Alex

採用された回答

Tim Berk
Tim Berk 2017 年 9 月 19 日
Contours can be drawn on a 2D slice in a 3D figure using contourslice.
I'm not sure what the contours are that you want to plot. I just specify some random contour in variable V.
Note that you are not projecting points at the wall, but at the location of the maximum. I fixed this by actually plotting at the limits.
x = mvnrnd(1, 3, 100);
y = mvnrnd(2, 3, 100);
z = mvnrnd(3, 3, 100);
scatter3 (x, y, z, 'filled')
hold on
xl = xlim;
yl = ylim;
zl = zlim;
xlim(xl); ylim(yl); zlim(zl); % fix the limits for if we rotate
scatter3 (0*x+xl(2), y, z, '.')
scatter3 (x, 0*y+yl(2), z, '.')
scatter3 (x, y, 0*z+zl(1), '.')
rotate3d on
[X,Y,Z]=meshgrid(round(xl(1)):round(xl(2)),round(yl(1)):round(yl(2)),round(zl(1)):round(zl(2)));
V = X.^2+Y.^2+Z.^2;
contourslice(X,Y,Z,V,xl(2),yl(2),[zl(1) zl(2)])
hold off
  1 件のコメント
Alex Kurek
Alex Kurek 2017 年 9 月 19 日
編集済み: Alex Kurek 2017 年 9 月 19 日
Thanky you. The contours are a bit displaced. This is the way to correct it:
V = (X-1).^2 + (Y-2).^2 + (Z-3).^2;
Best regards, Alex

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeContour Plots についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by