What is the Colormap for plotting weather radar velocity product with interval?
9 次查看(过去 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 中查找有关 Blue 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!