What is the Colormap for plotting weather radar velocity product with interval?
조회 수: 11 (최근 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!