0
votes

I have a contourfm plot on which I want to place a dot. The contourfm plot by itself works fine with no error. But when I try to place a dot at a specific point, it overrides the contourfm plot and just places a dot on a white background without the eqdconic figure and with the latitude and longitude lines squashed together. I am using hold on and I've tried plotting the data first and plotting the dot first, but both produce the same result. Can anyone tell me what I'm doing wrong? I think maybe I should not be using 'plot' as the command.

** The code has been modified to reflect the answer. plotm was used instead of plot. the x and y values for the dot was switched to reflect MATLAB's lat, lon order (instead of 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);
1

1 Answers

2
votes

1

Use plotm instead of plot.

2

Replace this line

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

with

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

Note that find returns the index of the found element not its value. However, in your case you can actually pass the actual values

3

If you will not use xValue and yValue later you can remove these lines

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

and change the plotting line to

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

4

However this will not plot the dot because the latitude and longitude are swapped comparing to the ranges you have mentioned in axesm command. But since you use contourfm(y,x), I assume there should be swapped so the plotting line will be

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

5

which gives us a blue dot, so we change the color to black by using 'k.' instead of 'b.' and we have

% 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

which produces enter image description here