Colormap always shades of blue

조회 수: 21 (최근 30일)
Lotmeri
Lotmeri 2021년 11월 26일
편집: DGM 2021년 11월 29일
Hello, I am having a problem with the colormap... I'd like to have a picture like the one on the top... I ran the code and then I re-run in another PC (with a different version of Matlab --> r2020 vs r2021b)... And what I obtained with the SAME code is the graph on the bottom. Do you have a solution? Because I red that it happens sometimes, but I couldn't find a solution. Thank you in advance.
  댓글 수: 2
Image Analyst
Image Analyst 2021년 11월 26일
Give your data values and the code used to make the plot. Make it EASY for us to help you, not hard.
Lotmeri
Lotmeri 2021년 11월 29일
angle=[5.58,3.49,4.19,0.35,2.79,3.49,3.14,3.49,3.14,5.58,0.35,0.35,3.14,3.84,2.79,3.84,3.14];
d=[15.83,8.46,11.69,10.18,11.05,10.79,6.72,10.59,9.89,10.23,10.33,9.32,10.02,8.14,10.88,8.07,6.61];
P=[-129.89,-129.76,-128.61,-128.32,-127.83,-127.75,-127.64,-127.40,-127.32,-127.22,-126.49,-125.19,-123.50,-120.44,-115.72,-111.30,-101.68];
Pmax=min(P);
Pmin=max(P);
delta_c = (Pmax - Pmin) / 63;
cmap_dB = Pmin + (0:63) * delta_c;
n_tot=length(P);
for index = 1:n_tot
h = polarplot(angle(index), dist_estim(index), 'o'); hold on;
[val, index_color] = min( abs( P(index) - cmap_dB ) );
map = colormap('jet');
set(h, 'MarkerFaceColor', map(index_color,:));
set(h, 'MarkerEdgeColor', map(index_color,:));
set(h, 'MarkerSize', 11);
end
Thank you.

댓글을 달려면 로그인하십시오.

채택된 답변

DGM
DGM 2021년 11월 29일
편집: DGM 2021년 11월 29일
You're not specifying your colormap length. If you don't do that, colormap() will create a map equal to the length of the current map. In earlier versions, the default length is 64, while in newer versions, it's 256. That said, if you had previously ran a script that set colormap(parula(17)), calling colormap(jet) will create a map of length 17 instead of 64 or 256. In other words, if you don't explicitly specify the map length, you have no control over how long the map is.
map = jet(numel(cmap_dB)); % just get the map; don't need colormap()
For what it's worth, you probably can also do this with polarscatter()
angle=[5.58,3.49,4.19,0.35,2.79,3.49,3.14,3.49,3.14,5.58,0.35,0.35,3.14,3.84,2.79,3.84,3.14];
d=[15.83,8.46,11.69,10.18,11.05,10.79,6.72,10.59,9.89,10.23,10.33,9.32,10.02,8.14,10.88,8.07,6.61];
P=[-129.89,-129.76,-128.61,-128.32,-127.83,-127.75,-127.64,-127.40,-127.32,-127.22,-126.49,-125.19,-123.50,-120.44,-115.72,-111.30,-101.68];
Pmax=min(P);
Pmin=max(P);
delta_c = (Pmax - Pmin) / 63;
cmap_dB = Pmin + (0:63) * delta_c;
map = jet(numel(cmap_dB)); % specify map length
[~,idx] = min( abs( P - cmap_dB.' ) );
h = polarscatter(angle, d, 75, map(idx,:), 'filled');

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Colormaps에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by