在matlab中将定制的色彩映射附加到geoshow [英] attaching customized colormap to geoshow in matlab

查看:1467
本文介绍了在matlab中将定制的色彩映射附加到geoshow的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使用geoshow命令在mollweide投影中绘制一个世界地图。但是,我不能基于cutomized色彩映射值修改图中的颜色。很可能这是一个问题,如何同时使用axesm和geoshow命令,请帮助我。参见参考文献。

  G = rand(180,360); 
G(1:90,:)= - 1 * G(1:90,:);
R = georasterref('RasterSize',size(G),...
'Latlim',[ - 90 90],'Lonlim',[-180 180],'ColumnsStartFrom','north ');

%ref此链接:http://stackoverflow.com/questions/34727526/matlab-plot-raster-map-with-custom-colormap/34740112#34740112
%设置图形参数
my_colormap = [254 204 92
253 141 60
240 59 32
189 0 38] / 255;

startval = min(min(G));
endval = max(max(G));
nElements = size(my_colormap,1);
stepSize =(endval-startval)/(nElements-1);
breaks = startval:stepSize:endval;
labels = textscan(num2str(round((breaks * 100))/ 100),'%s');
labels = labels {1};
[〜,indices] = histc(G,breaks);

%实际图形
figure
hm = axesm('mollweid','Frame','on','Grid','off');
geoshow(G,R);%geoshow(indices,R);

colormap(my_colormap);
set(gca,'color','none');
set(gca,'box','off','xtick',[],'xcolor','none')
set ,[],'ycolor','none')
hc = colorbar('location','southoutside');
caxis([breaks(1)breaks(length(breaks))])%caxis([0 length(breaks)-1])$ ​​b $ b hcP = [.7 .28 .2 .02]
set(hc,'position',hcP);
h.YTickLabel = labels;我的一个同事指出了我的解决方案,并且我的一个同事指出了我的解决方案。

发布它在这里供其他参考:
geoshow(G,R,'DisplayType','texturemap')


I am trying to plot a world map in mollweide projection using geoshow command. However, I am not able to modify the colors in the plot based on cutomized colormap values. Most likely this is an issue with how axesm and geoshow commands are used together, Please help me on this. See the ref. code below:

G = rand(180,360);
G(1:90,:)=-1*G(1:90,:);
R = georasterref('RasterSize',size(G),...
    'Latlim',[-90 90], 'Lonlim', [-180 180],'ColumnsStartFrom','north');

% ref this link: http://stackoverflow.com/questions/34727526/matlab-plot-raster-map-with-custom-colormap/34740112#34740112
%setting up graphics parameters 
my_colormap = [254  204   92
               253  141   60
               240   59   32
               189    0   38]/255 ;

startval=min(min(G));
endval=max(max(G));
nElements =size(my_colormap,1); 
stepSize=(endval-startval)/(nElements-1);
breaks = startval:stepSize:endval;
labels = textscan(num2str(round((breaks*100))/100),'%s') ;
labels = labels{1};
[~,indices] = histc(G,breaks);

%actual graphics               
figure
hm=axesm ('mollweid', 'Frame', 'on', 'Grid', 'off');
geoshow(G,R);%geoshow(indices,R);

colormap(my_colormap);
set(gca,'color','none');
set(gca,'box','off','xtick',[],'xcolor','none')
set(gca,'box','off','ytick',[],'ycolor','none')
hc=colorbar('location','southoutside');
caxis([breaks(1) breaks(length(breaks))])%caxis([0 length(breaks)-1])
hcP = [.7 .28 .2 .02];
set(hc,'position',hcP);
h.YTickLabel = labels ;

解决方案

one of my colleague pointed me to the solution and am posting it here for other's reference: geoshow(G,R,'DisplayType','texturemap')

这篇关于在matlab中将定制的色彩映射附加到geoshow的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆