What is the Colormap for plotting weather radar velocity product with interval?
9 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (1)
Voss
le 5 Juin 2022
Modifié(e) : Voss
le 5 Juin 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 commentaires
Walter Roberson
le 6 Juin 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
le 6 Juin 2022
Modifié(e) : Voss
le 6 Juin 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')
and apply it at will:
figure();
pcolor(randn(50));
colormap(S.cmap);
colorbar();
Voir également
Catégories
En savoir plus sur Blue dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!