How do I change color diffusion in jet colormap?

조회 수: 3 (최근 30일)
Bajdar Nouredine
Bajdar Nouredine 2021년 10월 11일
답변: Kevin Holly 2021년 10월 11일
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