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

64 visualizaciones (últimos 30 días)
Jinshi
Jinshi el 11 de Nov. de 2025 a las 2:54
Comentada: William Rose el 13 de Nov. de 2025 a las 1:54
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 comentarios
Jinshi
Jinshi el 12 de Nov. de 2025 a las 20:21
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 el 12 de Nov. de 2025 a las 22:40
I just moved it to an answer.

Iniciar sesión para comentar.

Respuesta aceptada

DGM
DGM el 12 de Nov. de 2025 a las 19:53
Movida: DGM el 12 de Nov. de 2025 a las 22:38
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.

Más respuestas (0)

Categorías

Más información sobre Data Distribution Plots en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2025a

Community Treasure Hunt

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

Start Hunting!

Translated by