From: <HIDDEN>
Path: news.mathworks.com!newsfeed-00.mathworks.com!webcrossing
Newsgroups: comp.soft-sys.matlab
Subject: Re: specify parent map axes?
Message-ID: <ef5bc6a.1@webcrossing.raydaftYaTP>
Date: Tue, 26 Jun 2007 14:24:44 -0400
References: <ef5bc6a.-1@webcrossing.raydaftYaTP> <ef5bc6a.0@webcrossing.raydaftYaTP>
Lines: 80
NNTP-Posting-Host: 128.61.191.50
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
Xref: news.mathworks.com comp.soft-sys.matlab:415861



here is a sample of my code, which is part of a pretty large gui
(unfortunately the sample is also long... but it's pretty
straightforward.) I think the reason your code works is that the
correct subplot is already the target (it becomes the target when you
create it), so the 'parent' in linem is redundant (why this matters,
I dont know, but it looks like it does):

thanks for your help!

f=figure;
handles.smallmapaxes=axes;
set(handles.smallmapaxes,'position',[.05 .3 .4 .4]);
handles.otheraxes=axes('position',[.55 .3 .4 .4]);

%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% make a little map
axes(handles.smallmapaxes)

handles.maxes=axesm('MapProjection','lambert','MapLatLimit',[10 65],
'MapLonLimit',[-150 -42]);

setm(gca,'FFaceColor',[0 0 .3]); %set ocean color
framem;

%sets axes to just focus on the usa...
set(gca,'xlim',[-.35 .32])
set(gca,'ylim',[.4 .9])

%plot canada and mexico
load coast
geoshow(lat,long,'DisplayType','polygon','FaceColor',[.1 .1
.1],'EdgeColor',[.8 .8 .8])
clear lat long

load conus.mat

handles.usmap=geoshow(uslat,uslon,
'DisplayType','polygon','FaceColor',[0 0 0], 'EdgeColor',[.8 .8 .8]);
geoshow(statelat,statelon,'DisplayType','line','Color',[.5 .5 .5])
geoshow(gtlakelat,gtlakelon, 'DisplayType','polygon','FaceColor',[0 0
.3], 'EdgeColor',[.8 .8 .8])

%% some sample data to plot
A =[

14 1393 18.439 65.984 40.64 73.779
7 1474.7 30.194 97.67 42.364 71.005
21 1321.2 30.194 97.67 40.64 73.779
7 1474.7 42.364 71.005 30.194 97.67
7 1521 42.364 71.005 39.858 104.67
39 1077.4 42.364 71.005 26.072 80.153
28 1087.7 42.364 71.005 26.536 81.755
7 2065.2 42.364 71.005 36.08 115.15
];
%% plot some lines on map

%somewhere along the line another axes gets made current:
axes(handles.otheraxes)

%now want to switch back and plot to the map:

%% this works:
%{
axes(handles.smallmapaxes)

for j=1:size(A,1)
    handles.currentroute(j)=linem([A(j,3) A(j,5)],...
        [-A(j,4) -A(j,6)],'Color',[.99 .60 .07],...
        'LineWidth',2,'hittest','off');
end

%}

%% this doesnt:

for j=1:length(A)
    handles.currentroute(j)=linem([A(j,3) A(j,5)],...
        [-A(j,4) -A(j,6)],'Color',[.99 .60 .07],...
        'LineWidth',2,'hittest','off','parent',handles.smallmapaxes);
end