How do I change color diffusion in jet colormap?

3 visualizzazioni (ultimi 30 giorni)
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;

Risposta accettata

Kevin Holly
Kevin Holly il 11 Ott 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:

Più risposte (1)

KSSV
KSSV il 11 Ott 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));

Categorie

Scopri di più su Colormaps in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by