How to plot contourf plot on one side of surf plot?
Mostrar comentarios más antiguos
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
William Rose
el 11 de Nov. de 2025
Is the image above an example of what you want? The image does not look like your description of what you want. Perhaps I don't understand what you want.
If you have arrays X, Y, and Z(X,Y), then what do you want to plot on the x-z plane or on the y-z plane?
Here is an example of a 3D scatter plot with the marginal probability density (i.e. histogram) projected onto one side. Source. Is this what you want?

The example below (https://www.sciencedirect.com/science/article/pii/S0165027004004418) is a plot of the time-dependent fourier transform, where the signal anmplitude versus time is also plotted on one side. You can imagine plotting the TDFT as a 3D surface, and plotting the amplitude versus time on one "wall", and plotting the 1D FFT on the other "wall". Plot below illustrates this concept (using only the TDFT and the amplitude versus time plot) but it does not use 3D plotting. Is this what you want, but you want it in 3D?

Please supply an example image and the journal source for it, and supply some sample data. Thank you.
Jinshi
el 11 de Nov. de 2025
dpb
el 12 de Nov. de 2025
It's not possible to do that with the builtin MATLAB countourf function, no.
import numpy as np
import plotly.plotly as py
and so were drawn with it, not with base MATLAB handle graphics functions.
One could paint pixels in the proper locations to appear as desired in MATLAB-only code, but one would have to do all the orthographic projection calculations explicitly in order to do so. It simply isn't possible to rotate the plane of any of the builtin 3D functions; they are all of the z=f(x,y) functional form and that is invariant(*).
(*) Well, I suppose one could add a second to the original axes and then figure out how to mung on the X-, Y-, CData arrays. I've made no efforts along that line as to feasibility.
Jinshi
el 12 de Nov. de 2025
Do you actually want a contour plot? What's shown is a pcolor plot. If you don't need discrete contour levels, then a pseudocolor image oriented outside the xy plane can either be done with pcolor() and some object manipulation, or it can be done using surf() and appropriate input ordering.
I don't know of a way to make it work with contourf(), though I vaguely remember going down this road before.
Jinshi
el 12 de Nov. de 2025
DGM
el 12 de Nov. de 2025
I had a half-baked generic example put together, but give me a bit and I'll see if I can adapt it to your data. That way I don't set you up for a problem I didn't expect.
Jinshi
el 12 de Nov. de 2025
DGM
el 12 de Nov. de 2025
I just moved it to an answer.
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Data Distribution Plots en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
