How to combine multiple contourf plots into one 3d contour plot?

16 次查看(过去 30 天)
I have contour plots on 3 faces of a solid object; front xy, bottom xz and rear xy. Further analysis takes quite some time in working on 3 contour plots which I plan to reduce by combining these to a 3d contour plot. For intermediate points, I would like to linearly interpolate the values inside the solid object. I have experimented with matlab a lot but when it comes to 3D plotting, things get complicated for me. I will show my contours to you and then explain after plotting them
clc
clear all
close all
load('Data_trimmed.mat')
x1 = x1 - 150;
x2 = x2 - 150;
x3 = x3 - 150;
figure('units','inch','position',[30,5,3,5]);
tiledlayout(3,1,"TileSpacing","tight","Padding","compact")
nexttile
hold on
rectangle('Position',[0 0 300 300],'FaceColor',[1 1 1],FaceAlpha=0.5)
[c12,h12] = contourf(x1,y1,ua, 'ShowText','on',FaceAlpha=0.6,EdgeAlpha=0.5,EdgeColor='k',LevelStep=10);
clabel(c12,h12,'FontSize',7,'Color','k',fontname='Times New Roman')
contourcmap("parula",20,"Colorbar","off")
xlim([0 300])
ylim([0 300])
title('xy plane with z = 0')
nexttile(2)
hold on
xline(1150,':r','Alpha',0.5,'FontSize',6,Interpreter='latex')
rectangle('Position',[0 0 300 200],'FaceColor',[1 1 1],FaceAlpha=0.5)
[d12,k12] = contourf(x2,z2,va, 'ShowText','on',FaceAlpha=0.6,EdgeAlpha=0.5,EdgeColor='k',LevelStep=10);
clabel(d12,k12,'FontSize',7,'Color','k',fontname='Times New Roman')
contourcmap("parula",20,"Colorbar","off")
ylim([0 200])
axis ij
xlim([0 300])
title('xz plane with y = 0')
nexttile(3)
hold on
xline(1150,':r','Alpha',0.5,'FontSize',6,Interpreter='latex')
rectangle('Position',[0 0 300 300],'FaceColor',[1 1 1],FaceAlpha=0.5)
[e12,m12] = contourf(x3,y3,wa, 'ShowText','on',FaceAlpha=0.6,EdgeAlpha=0.5,EdgeColor='k',LevelStep=10);
clabel(e12,m12,'FontSize',7,'Color','k',fontname='Times New Roman')
contourcmap("parula",20,"Colorbar","off")
xlim([0 300])
ylim([0 300])
title('xy plane with z = 200, shown inverted')
axis ij
In the figture above, the first plot shows xy contour on front face, the second plot shows the contour on bottom face and the 3rd shows on back face (inverted). It is shown in a way that it looks like an unwrapped surface contours. I plan to make 1 3d contour plot which gives these values on the outer surfaces but interpolated values inside the solid. If you need more information, we can discuss in the comments. The values do not start from the zero edges exactly, and can be extrapolated later on. I am only interested in plotting the 3d contour plot. Your help will be appreciated.
Thank you
Best
  2 个评论
Star Strider
Star Strider 2025-3-18
Looking aat these as surf plots makes them a bit easier to understand. What do they represent? (The data source is not important. The context — what they represent — is important.)
I do not understand what you want to do with them.
clc
clear all
close all
load('Data_trimmed.mat')
x1 = x1 - 150;
x2 = x2 - 150;
x3 = x3 - 150;
figure('units','inch','position',[30,5,3,5]);
tiledlayout(3,1,"TileSpacing","tight","Padding","compact")
nexttile
hold on
rectangle('Position',[0 0 300 300],'FaceColor',[1 1 1],FaceAlpha=0.5)
[c12,h12] = contourf(x1,y1,ua, 'ShowText','on',FaceAlpha=0.6,EdgeAlpha=0.5,EdgeColor='k',LevelStep=10);
clabel(c12,h12,'FontSize',7,'Color','k',fontname='Times New Roman')
contourcmap("parula",20,"Colorbar","off")
xlim([0 300])
ylim([0 300])
title('xy plane with z = 0')
nexttile(2)
hold on
xline(1150,':r','Alpha',0.5,'FontSize',6,Interpreter='latex')
rectangle('Position',[0 0 300 200],'FaceColor',[1 1 1],FaceAlpha=0.5)
[d12,k12] = contourf(x2,z2,va, 'ShowText','on',FaceAlpha=0.6,EdgeAlpha=0.5,EdgeColor='k',LevelStep=10);
clabel(d12,k12,'FontSize',7,'Color','k',fontname='Times New Roman')
contourcmap("parula",20,"Colorbar","off")
ylim([0 200])
axis ij
xlim([0 300])
title('xz plane with y = 0')
nexttile(3)
hold on
xline(1150,':r','Alpha',0.5,'FontSize',6,Interpreter='latex')
rectangle('Position',[0 0 300 300],'FaceColor',[1 1 1],FaceAlpha=0.5)
[e12,m12] = contourf(x3,y3,wa, 'ShowText','on',FaceAlpha=0.6,EdgeAlpha=0.5,EdgeColor='k',LevelStep=10);
clabel(e12,m12,'FontSize',7,'Color','k',fontname='Times New Roman')
contourcmap("parula",20,"Colorbar","off")
xlim([0 300])
ylim([0 300])
title('xy plane with z = 200, shown inverted')
axis ij
figure
tiledlayout(3,1)
nexttile
surf(ua)
title('ua')
nexttile
surf(va)
title('va')
nexttile
surf(wa)
title('wa')
.
Muha
Muha 2025-3-18
I had previously consulted this forum for plotting contour plots in 2d. And my purpose later was to interpolate one value which would result in giving a contour line (for instance, 20). This is extension of that in 3d. I have measured the 'intensities' on each face and plotted the contour plots only on those faces. You may think of it as looking at a room from outside where you can see the outside walls only for the relevant data (and that is the only data available). I just want to interpolate the 'indoors' data using the data from these three faces and make a 3D field (for now). And I would look up for a constant value in this intensity field. I hope it makes sense.
I have attached a sketch for the reference. It is very distorted but it looks like we have information about 3 faces. I want to interpolate the insides (grey part) and make a complete xyz field rather than planes of contours. Is it possible?
clc
clear all
close all
load('Data_trimmed.mat')
x1 = x1 - 150;
x2 = x2 - 150;
x3 = x3 - 150;
figure('units','inch','position',[30,5,3,5]);
tiledlayout(3,1,"TileSpacing","tight","Padding","compact")
nexttile
hold on
rectangle('Position',[0 0 300 300],'FaceColor',[1 1 1],FaceAlpha=0.5)
[c12,h12] = contourf(x1,y1,ua,[20 20], 'ShowText','on',FaceAlpha=0.6,EdgeAlpha=0.5,EdgeColor='k',LevelStep=10);
clabel(c12,h12,'FontSize',7,'Color','k',fontname='Times New Roman')
contourcmap("parula",20,"Colorbar","off")
xlim([0 300])
ylim([0 300])
title('xy plane with z = 0')

请先登录,再进行评论。

回答(1 个)

Cris LaPierre
Cris LaPierre 2025-3-18
  1 个评论
Muha
Muha 2025-3-18
Well, this gives a very good starting point, I will adopt this into my framework and get back after this approach works. Thank you for telling.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Surface and Mesh Plots 的更多信息

产品


版本

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by