当前位置: 动力学知识库 > 问答 > 编程问答 >

Mapping in MATLAB - TVMap style (square boxes)

问题描述:

I want to make a map of the U.S. and plot grid cells onto it. Each grid cell has a data value and will be filled in with a color from a colorbar.

In IDL, maybe in a special package, I'm not sure, there's a command called tvmap that does this. I don't know how to replicate it in MATLAB.

It should look like this:

I have the 'lat' and 'lon' values as a column of numbers. Each lat and lon pair defines the CENTER of a box. A 'data' variable contains the value that is supposed to go into that box.

Here's what I have so far. This part just creates a map of the U.S. and a colorbar. I don't know how to map colored grids onto it.

figure(1);

ax = usamap('conus');

set(ax, 'units','normalized','outerposition',[0 0 1 1]);

states = shaperead('usastatelo', 'UseGeoCoords', true,...

'Selector',...

{@(name) ~any(strcmp(name,{'Alaska','Hawaii'})), 'Name'});

geoshow(ax, states,'FaceColor', 'none', 'EdgeColor', [0.5 0.5 0.5])

framem off; gridm off; mlabel off; plabel off

set(gca,'Visible','on');

hold on

% Colorbar

caxis([10 80]);

h = colorbar('location', 'EastOutside');

ylabel(h,'MDA8 O_3');

% Title

title(['Correlation Between Monthly Mean Obs and Base Simulation in ', cell2mat(cellstr(years))]); % Title changes every daytitle(str);

网友答案:

I think

image

is the command you are looking for.

网友答案:

pcolorm(lat,lon,data) does the trick. Make sure lat and lon and data are the same size. In terms of a map, that means making a matrix of lat and lon values corresponding to each data point.

The result (with dots plotted on top) looks like this:

分享给朋友:
您可能感兴趣的文章:
随机阅读: