How to overlay two surf plots?

조회 수: 17 (최근 30일)
LEONG SING YEW
LEONG SING YEW 2020년 3월 14일
댓글: LEONG SING YEW 2020년 3월 22일
Hi everyone,
I am trying to overlay the contour stroke shape into the colorful surf plot
Here the code i've tried but it doesnt work, it only show the left image above
hold on
surf(X,Y,-M1); surf(-X,Y,M1); %Reflection along y axis
surf(X,Y,Ta); surf(-X,Y,Ta); %Stroke Contour
  댓글 수: 4
Walter Roberson
Walter Roberson 2020년 3월 15일
It would help if we had your data to work with -- X, Y, and M1 and Ta
LEONG SING YEW
LEONG SING YEW 2020년 3월 15일
Yes you may have my code and my data in the csv attachment,
The picture shown is what i'm trying to do: to overlay the black stroke of the flame front on the colorful surf plot
colormap jet
%{
Read data
%}
filename0 = '0.csv';
Data0 = csvread(filename0,6,0);
filename1 = '360.csv';
Data1 = csvread(filename1,6,0);%skip 6 header lines
%{
Data Extraction
%}
X_Data = Data0(:,2); Y_Data = Data0(:,1); %x and y coordinates
%Extract both temperature and x-velocity data
T_Data0 = Data0(:,8); V_Data0 = Data0(:,9);
T_Data1 = Data1(:,8); V_Data1 = Data1(:,9);
V_Data1 = V_Data1-V_Data0; %Fluctuation velocity, v'
V_Data1(T_Data1>400)=0; %Temperature outside the flame front is not considered
T_1=V_Data1-1; %Create flame front stroke by darken it using caxis later, or any alternative method
T_1(T_Data1>500)=NaN; T_1(T_Data1<325)=NaN; %Only circumference of flame front is needed
%{
Surf
%}
[x,~,xi]=unique(X_Data*1e3/2); %convert m to mm
[y,~,yi]=unique(Y_Data*1e3/2);
subs=[xi yi];%use the indices instead of values as coordinates
[X,Y]=ndgrid(x,y);%generate the grid surf() expects
Ta =accumarray(subs,T_1,[],[],NaN);
M1=accumarray(subs,V_Data1,[],[],NaN);%fill missing with NaN
hold on
surf(-X,Y,M1); surf(X,Y,-M1); %Reflection along y-axis
surf(-X,Y,Ta); surf(X,Y,Ta); %Stroke Contour
shading interp; c=colorbar;
xlim([-2 2]); ylim([-0.5 3.4]);
xlabel("x/R (mm)"+newline);ylabel("y/R (mm)"+newline)
title(c,"v'/U_o",'FontSize',9,'FontWeight','bold');
title('Phase = 0\circ')
caxis([-.1 .1]) %Set the range
view(0,90);

댓글을 달려면 로그인하십시오.

채택된 답변

Walter Roberson
Walter Roberson 2020년 3월 16일
view(0,-90)
  댓글 수: 4
Walter Roberson
Walter Roberson 2020년 3월 22일
plot() creates a 3D plot with empty Z components, and that in turn is treated the same as if the Z components were all 0. You can use plot3() to provide explicit Z coordinates; you would want to use a Z larger than the largest Z in the surf plot.
I wonder if pcolor() would be better than surf() for your purpose? pcolor is a surface plot underneath, but it creates a surface in which all the Z are 0 and the color data is set according to the Z data that was passed to pcolor(). Using Z all 0 can make it easier to draw things on top of it.
LEONG SING YEW
LEONG SING YEW 2020년 3월 22일
omg, i didn't know this command "pcolor" exist, amazing!!! Thank you so much!!!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Lighting, Transparency, and Shading에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by