How do I change color diffusion in jet colormap?

4 次查看(过去 30 天)
I want to show the red color at the center of the sphere and the blue at the circumstances (i.e color distributed inversly)
%% Example data
x = (2:-0.1:0);
data = sin(x);
%% Shift the values towards the center, so you get a circle instead of an annulus.
rho = x-min(x);
%% Your meshgrid generation code.
theta = (0:360)*pi/180;
[th, r] = meshgrid(theta, rho);
%% Plotting the values
surf(min(x)+r.*cos(th), ...
min(x)+r.*sin(th), ...
repmat(data(:), 1, size(th,2)), ...
'linestyle', 'none');
view(2);
axis equal tight;
colorbar;
colormap jet;

采纳的回答

Kevin Holly
Kevin Holly 2021-10-11
%% Example data
x = (2:-0.1:0);
data = sin(x);
%% Shift the values towards the center, so you get a circle instead of an annulus.
rho = x-min(x);
%% Your meshgrid generation code.
theta = (0:360)*pi/180;
[th, r] = meshgrid(theta, rho);
%% Plotting the values
surf(min(x)+r.*cos(th), ...
min(x)+r.*sin(th), ...
repmat(data(:), 1, size(th,2)), ...
'linestyle', 'none');
view(2);
axis equal tight;
colorbar;
colormap jet;
You can add the following:
colormap(flip(jet));
FYI, you can customize the color part as such:

更多回答(1 个)

KSSV
KSSV 2021-10-11
%% Example data
x = (2:-0.1:0);
data = sin(x);
%% Shift the values towards the center, so you get a circle instead of an annulus.
rho = x-min(x);
%% Your meshgrid generation code.
theta = (0:360)*pi/180;
[th, r] = meshgrid(theta, rho);
%% Plotting the values
surf(min(x)+r.*cos(th), ...
min(x)+r.*sin(th), ...
repmat(data(:), 1, size(th,2)), ...
'linestyle', 'none');
view(2);
axis equal tight;
colorbar;
colormap(flipud( jet));

类别

Help CenterFile Exchange 中查找有关 Colormaps 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by