What is the Colormap for plotting weather radar velocity product with interval?

21 views (last 30 days)
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

Answers (1)

Voss
Voss on 5 Jun 2022
Edited: Voss on 5 Jun 2022
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 Comments
Walter Roberson
Walter Roberson on 6 Jun 2022
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
Voss on 6 Jun 2022
Edited: Voss on 6 Jun 2022
@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')
S = struct with fields:
cmap: [262×3 uint8]
and apply it at will:
figure();
pcolor(randn(50));
colormap(S.cmap);
colorbar();

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!