Use image function to create heat map and 3D plot?

11 次查看(过去 30 天)
I have 4 variables (X, Y, Z, W) I am trying to plot at the same time. I already have code set up to plot a heat map showing population count over a range of X and Y values. These population values are found in variable Z. However, now I am trying to make a 3D heat map using the image function to add in height values, found in variable W. How would I go about doing this? I want the heat map and colorbar to show the range of values for population count, not height. The z axis can just show the height values. I am able to use surfc to plot X,Y,W as seen below too, but I don't know how to combine the two plots. The four variables are attached as .mat files.
traj_xmin = 0; % traj plot axis limits
traj_xmax = 3200;
traj_ymin = 0;
traj_ymax = 1400;
figure(1)
im = image('XData', [traj_xmin traj_xmax], 'YData', [traj_ymin traj_ymax], 'CData', Z, 'CDataMapping', 'scaled');
colormap(flipud(pink));
colorbar
AxesH = gca;
axis(AxesH, 'tight');
figure(2)
rotate3d
surfc(X,Y,W);
colorbar
AxesH = gca;
axis(AxesH, 'tight');
zlim([0 200]);

回答(1 个)

Arun Mathamkode
Arun Mathamkode 2018-2-1
You can use the cdata property in the surface properties to assign vertex colors on a surface.
figure,surf(X,Y,Z,'cdata',W);

类别

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

Community Treasure Hunt

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

Start Hunting!

Translated by