Color map jet from center

3 次查看(过去 30 天)
Kavish Ram
Kavish Ram 2020-10-11
Hi,
I am trying to make the colour map 'jet' apper red in the center and go outwards.
I have tried using flipud but it simply inverts it, making the red go at the bottom, so not what I am looking for.
Also,
I am trying to get my lines in the statement
line(x ,y,z, 'LineStyle', '-');
appear in the colormap jet as well. I have tried muiltple times but gives me an error.
Full code :
x = DistanceX .* cos(AngleX);
y = DistanceY .* sin(AngleY);'
z = DistanceZ .* cos(AngleZ) ;
load flujet
figure;
grid on;
scatter3 (x,y,z, [] , z);
line(x ,y,z, 'LineStyle', '-' );
colormap (flipud(jet))
  1 个评论
Image Analyst
Image Analyst 2020-10-11
No, that's not the full code. Not only does it throw a syntax error, but there is no assignment oa DistanceX, AngleX, etc. Please post your full code, and include the flujet.mat file (if it's not a built-in one that's shipped with MATLAB).

请先登录,再进行评论。

回答(2 个)

Ameer Hamza
Ameer Hamza 2020-10-11
编辑:Ameer Hamza 2020-10-11
Something like this?
cm = jet;
cm = circshift(cm, round(size(cm, 1)/2), 1);
image(reshape(cm, 256, 1, []));

Image Analyst
Image Analyst 2020-10-11
Is this what you mean?
% Create colormap with jet where red is at the center and blue is at the ends.
cmap = [jet; flipud(jet)];
% Create a simple image that is a ramp of gray scales.
ramp = uint8(repmat((0:255)', [1, 512]));
% This is what it looks like in gray scale.
subplot(2, 1, 1);
imshow(ramp, 'ColorMap', gray(256))
colorbar
title('This is what it looks like in gray scale.');
% This is what it looks like in pseudocolor.
subplot(2, 1, 2);
imshow(ramp, 'ColorMap', cmap)
colorbar
title('This is what it looks like in pseudocolor.');

类别

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

Community Treasure Hunt

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

Start Hunting!

Translated by