What is the Colormap for plotting weather radar velocity product with interval?
13 ビュー (過去 30 日間)
古いコメントを表示
I need the velocity colormap that woud generate the python image attached.
This code does not work for matlab.
----------------------------------------------------------
figure('position',[50 100 1800 800])
pcolor(datenum(time),rng,zh)
datetick('x')
shading flat
set(gca,'color','w','LineWidth',1,'fontweight','bold','fontsize',15);
xlabel('\bf{Time (UTC)}','FontSize',12,'FontWeight','bold','color','k');
ylabel('\bf{Height (km)}','FontSize',12,'FontWeight','bold','color','k');
ylim([0.1 10])
caxis([-6 6])
title(['2021-12-24 ' ...
'Velocity (m/s)']);
%mean_doppler_velocity
cb = colorbar;
cb.Label.String = 'Velocity (m/s)';
colormap vel
0 件のコメント
回答 (1 件)
Voss
2022 年 6 月 5 日
編集済み: Voss
2022 年 6 月 5 日
You can take the colors directly from the colorbar in the image, and use them as your colormap:
data = imread('velocity plot.jpg');
cmap = permute(data(288:-1:27,903,:),[1 3 2]);
colormap(cmap)
colorbar();
Or maybe one of the colormaps here (or in another File Exchange submission) is similar enough:
4 件のコメント
Walter Roberson
2022 年 6 月 6 日
I would suggest unique() by rows, as colorbar are guaranteed to have to have repeated rows if the number of entries in the map is fewer than the number of pixels used to plot the map.
Voss
2022 年 6 月 6 日
編集済み: Voss
2022 年 6 月 6 日
@Walter Roberson makes a good point. This will read the colormap colors from the colorbar portion of the image and remove any repeated colors:
% generating the colormap:
data = imread('velocity plot.jpg');
cmap = unique(permute(data(288:-1:27,903,:),[1 3 2]),'rows','stable');
% applying the colormap:
colormap(cmap)
colorbar();
In addition to that, I'll point out that you can save the colormap for your own use later (so you don't have to go through reading this .jpg each time you need this colormap) by storing it in a mat file:
save('blue_white_red.mat','cmap');
And load it later when you want to use it:
S = load('blue_white_red.mat')
and apply it at will:
figure();
pcolor(randn(50));
colormap(S.cmap);
colorbar();
参考
カテゴリ
Help Center および File Exchange で Colormaps についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!