0

我有一个轮廓图,我想在上面放置一个点。contourfm 图本身可以正常工作,没有错误。但是当我尝试在特定点放置一个点时,它会覆盖轮廓图,只是在没有 eqdconic 图形且纬度和经度线挤压在一起的白色背景上放置一个点。我正在使用hold on,我尝试先绘制数据并先绘制点,但两者都产生相同的结果。谁能告诉我我做错了什么?我想也许我不应该使用“情节”作为命令。

** 代码已被修改以反映答案。使用 plotm 代替 plot。点的 x 和 y 值被切换以反映 MATLAB 的 lat、lon 顺序(而不是 lon、lat。)

% Eqdconic script    
    % Define figure and axes
    fg1 = figure(1);
    % set(fg1, 'paperposition', [0 0 8.5 8.5]);
    axesm('MapProjection','eqdconic', 'MapParallels', [], 'MapLatLimit',[-80 -60],'MapLonLimit',[190 250]) % 60-70S and 120-160W
    framem on; gridm on; mlabel on; plabel on; hold all;

    % Old code that was incorrect:
         % xValue = find(x(:,1) == 224); % Longitude closest to  136 03.56W
         % yValue = find(y(1,:) == -66.75); % Latitude closest to 66 39.67S
         % plot(xValue,yValue,'b.','MarkerSize',20);  % Plot a black dot

    % Plot dot    
    plotm(-66.75,224,'k.','MarkerSize',20); 

    hold on

    % Plot data
    frame = dataPoint(:,:,k);
    contourfm(y,x,frame, 'LineStyle', 'none');

    % Colorbar
    caxis([0 100]); 
    h = colorbar;
    ylabel(h,'Percent');

    % Title: Days 1:1258 inclusive. 20100101 to 20130611
    date = datenum(2009, 12, 31) + k; % Convert t into serial numbers
    str = datestr(date, 'mmm yyyy');
    title(str);
4

1 回答 1

2

1

使用plotm而不是plot.

2

替换此行

plot(xValue,yValue,'b.','MarkerSize',20);  % Plot a black dot

plotm(x(xValue,1),y(1,yValue),'b.','MarkerSize',20);  % Plot a black dot

请注意,find返回找到的元素的索引而不是它的值。但是,在您的情况下,您实际上可以传递实际值

3

如果您不使用xValueyValue以后可以删除这些行

xValue = find(x(:,1) == 224); % Longitude closest to  136 03.56W
yValue = find(y(1,:) == -66.75); % Latitude closest to 66 39.67S

并将绘图线更改为

plotm(224,-66.75,'b.','MarkerSize',20);  % Plot a black dot

4

但是,这不会绘制点,因为与您在axesm命令中提到的范围相比,纬度和经度是交换的。但是由于您使用contourfm(y,x),我认为应该交换所以绘图线将是

plotm(-66.75,224,'b.','MarkerSize',20);  % Plot a black dot

5

'k.'这给了我们一个蓝点,所以我们通过使用而不是将颜色更改为黑色'b.',我们有

% Eqdconic script    
    % Define figure and axes
    fg1 = figure(1);
    % set(fg1, 'paperposition', [0 0 8.5 8.5]);
    axesm('MapProjection','eqdconic', 'MapParallels', [], 'MapLatLimit',[-80 -60],'MapLonLimit',[190 250]) % 60-70S and 120-160W
    framem on; gridm on; mlabel on; plabel on; hold all;
    plotm(-66.75,224,'k.','MarkerSize',20);  % Plot a black dot

产生 在此处输入图像描述

于 2013-07-05T16:13:03.540 回答