简体   繁体   English

3d中的Matlab 2d等高线图

[英]Matlab 2d contour plot in 3d

I would like to plot a 2d contour plot in 3d space but it should not be on the XY plane but on the ZX plane.我想在 3d 空间中绘制一个 2d 等高线图,但它不应该在 XY 平面上,而应该在 ZX 平面上。 Is there a way to change the plane on which it is ploted?有没有办法改变绘制它的平面?

Here is some example:下面是一些例子:

figure;
contourf(ZZ1,YZ1,EH);

hold all;

line([0 0],[0 0],[0 1]);
view(25,20);

Output:输出:

在此处输入图片说明

And I want the Contour plot on the plane facing me!我想要平面上的轮廓图面向我!

This is just a rough idea of how it could work using contourslice :这只是关于如何使用contourslice工作的粗略想法:

p = peaks(21);
contourf(p);
view(25,20);

在此处输入图片说明

Insert your data instead of peaks(21) and be careful with the dimensions.插入您的数据而不是peaks(21)并注意尺寸。 Then you can do something like然后你可以做类似的事情

%Get a grid for your data. x and z have dimensions of your old data grid,
%y will is used to build a volume, which will have three slices with the
%data, which is necessary because contourslice takes a volume, not a surface
x = -2:0.2:2;
y = -0.1:0.1:0.1;
z = -2:0.2:2;
[X,Y,Z] = meshgrid(x,y,z);
%Make your data matrix (which is 2D so far) 3D by repeating 3 times in Z
u = repmat(p, [1, 1, 3]);
Sx = []; %No planes to be drawn orthogonal to X
Sy = 0;  %One plane to be drawn orthogonal to Y
Sz = []; %No planes to be drawn orthogonal to Z
%Only draw one of your three y planes. Change X and Z.
figure;
contourslice(X,Y,Z,permute(u,[3, 2, 1]),Sx,Sy,Sz)
view(25,20);

to get要得到

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM