フィルターのクリア

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

11 ビュー (過去 30 日間)
Andrew Poissant
Andrew Poissant 2018 年 1 月 25 日
回答済み: Arun Mathamkode 2018 年 2 月 1 日
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 Center および File ExchangeSurface and Mesh Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by