How to plot contourf plot on one side of surf plot?

조회 수: 11 (최근 30일)
Jinshi
Jinshi 2025년 11월 11일
댓글: William Rose 2025년 11월 13일
I saw a plot in the journal that I want to replicate in Matlab (the original plot is done by Python, I think). The plot shows a 2D wavy interace with 2D velocity profile on the sides of the plot. In Matlab, I can use surf to create 2D wave interace as a function of x and y where the height is in z. However, I am not sure how I could plot these 2D velocity profile in x-z or y-z plane. If just use contourf to plot it, it will plot on the x-y axis as default. Therefore I am wondering whether it is possible to plot contourf on select axis with the surf plot? Thank you!
  댓글 수: 9
Jinshi
Jinshi 2025년 11월 12일
Wow @DGM this is exactly what I need! What a clever way to solve my question. The colormap is not a problem (yet) since there is no colormap on eta and the colormap for my x-z and y-z plot should be the same. I'd like to accept your answer but it seems that you put this in the comment section rather than the answer section... Please let me know how to accept your answer and I am more than happy to do that!
Best,
Jinshi
DGM
DGM 2025년 11월 12일
I just moved it to an answer.

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

채택된 답변

DGM
DGM 2025년 11월 12일
이동: DGM 2025년 11월 12일
This is a start.
load data_3D_2D.mat
surf(xx_eta,yy_eta,eta,'edgecolor','none');
hold on; grid on; axis equal
yy_u = max(yy_eta(:))*ones(size(xx_u)); % constant y-data at the edge of the plot
surf(xx_u,yy_u,zz_u,u,'edgecolor','none','facelighting','none');
Depending on your expectations, it might need to get more complicated. One potential issue is that both of these objects use the same colormap and color scaling (i.e. clim()). Since an axes has one set of color mapping properties, if you wanted to use different colormaps or color scales, the way around that is to use multiple overlaid axes.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Distribution Plots에 대해 자세히 알아보기

제품


릴리스

R2025a

Community Treasure Hunt

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

Start Hunting!

Translated by