How do I change color diffusion in jet colormap?

3 views (last 30 days)
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;

Accepted Answer

Kevin Holly
Kevin Holly on 11 Oct 2021
%% 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:

More Answers (1)

KSSV
KSSV on 11 Oct 2021
%% 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));

Categories

Find more on Colormaps in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!