我一直在嘗試更改 3D 上顏色條軸上的刻度,但遇到了問題,如果我這樣做,整個 3D 圖形上的顏色都會發生變化。基本上我想要做的是在 3D 圖形上保持相同型別的顏色范圍,同時將顏色條值從 0 - 80 更改為 50 - 450,而不更改實際圖形上的顏色。
提前致謝!
clc;
clear all;
close all;
filename = ['*File pathway to the datafiles*' 'filenames.txt'];
T = readtable(filename);
tsize = size(T);
tsize (1);
filename = strcat('*File pathway to the datafiles*', string(T{1,1}));
heat = double(getHeatMap(filename));
%load('myMap2.mat');
figure
set(gcf,'Visible','on')
for i = 1:tsize
filename = strcat('*File pathway to the datafiles*', string(T{i,1}));
if dir(filename).bytes == 0
continue;
end
heat = double(getHeatMap(filename));
[X,tY] = meshgrid( linspace(1,400,size(heat,2)),linspace(0,2*pi,size(heat,1)));
max_heat = max(heat, [], 'all');
min_heat = min(heat, [], 'all');
R = (((heat-min_heat)/(max_heat-min_heat))*50) 100;
Y = cos(tY) .* R;
Z = sin(tY) .* R;
[nx, ny, nz] = surfnorm(X,Y,Z);
nv = reshape([nx ny nz], size(nx,1),size(nx,2),3);
CV = R;
s = surf(X,Y,Z,heat,'VertexNormals',nv, 'EdgeColor','none');
axis([0 400 -200 200 -200 200])
colorbar
colormap('parula')
lighting gouraud
camlight
material dull
caxis([0 80])
drawnow
end
function heat = getHeatMap(filename)
s = dir(filename);
fin=fopen(filename,'r');
I=fread(fin,s.bytes,'uint8=>uint8');
w = uint16(I(1)) 256*uint16(I(2));
h = uint16(I(3)) 256*uint16(I(4));
skip = s.bytes - w*h 1;
IN = I(skip:1:s.bytes);
Z=single(reshape(IN,w,h));
Z=griddedInterpolant(Z');
y_range = linspace(1.0,single(h),256);
x_range = linspace(1.0,single(w),512);
heat = uint8(Z({y_range, x_range}));
end

使用 caxis([50 450]) 在 50 - 450 范圍內更改顏色條軸后

uj5u.com熱心網友回復:
表面的顏色由您指定,作為沖浪的輸入熱量。感覺這里的簡單事情就是簡單地改變輸入。
如果你只是這樣做,surf(X,Y,Z, heat*400/80 50 ,....你應該得到你想要的。
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/336440.html
上一篇:生成不重復的組合(排列)矩陣(陣列超過最大陣列大小首選項)
下一篇:矩陣的秩與獨立列數矛盾
