【问题标题】:attaching customized colormap to geoshow in matlab在matlab中将自定义颜色图附加到geoshow
【发布时间】:2017-01-02 12:13:37
【问题描述】:

我正在尝试使用 geoshow 命令在 mollweide 投影中绘制世界地图。但是,我无法根据自定义颜色图值修改图中的颜色。这很可能是axsm和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 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 ;

【问题讨论】:

    标签: matlab colors geospatial raster


    【解决方案1】:

    我的一位同事向我指出了解决方案,并将其发布在这里以供其他人参考: geoshow(G,R,'DisplayType','texturemap')

    【讨论】:

      猜你喜欢
      • 2021-07-08
      • 1970-01-01
      • 1970-01-01
      • 2013-12-11
      • 1970-01-01
      • 2011-09-18
      • 2016-12-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多