Colormap always shades of blue
11 ビュー (過去 30 日間)
古いコメントを表示
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.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/813979/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/813984/image.png)
2 件のコメント
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.
採用された回答
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 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Colormaps についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!