Use image function to create heat map and 3D plot?
조회 수: 6 (최근 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]);
댓글 수: 0
답변 (1개)
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);
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!