Colorbar 轴在 Matlab 中改变 3D 图形的颜色

Colorbar axis ticks changing color on 3D figure in Matlab

我一直在尝试更改 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

Pastebin link to the datafile, should be saved as 0000.OTT so it can be run.

颜色条轴变化之前

使用 caxis([50 450]) 在 50 - 450 范围内更改颜色条轴后

表面的颜色是你给的,作为冲浪的输入热量。感觉这里简单的事情就是简单地改变输入。

如果你只做 surf(X,Y,Z, heat*400/80+50 ,.... 你应该得到你想要的。