How do I change color diffusion in jet colormap?

3 Ansichten (letzte 30 Tage)
Bajdar Nouredine
Bajdar Nouredine am 11 Okt. 2021
Beantwortet: Kevin Holly am 11 Okt. 2021
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;

Akzeptierte Antwort

Kevin Holly
Kevin Holly am 11 Okt. 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:

Weitere Antworten (1)

KSSV
KSSV am 11 Okt. 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));

Kategorien

Mehr zu Colormaps finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by