Thread Subject: specify parent map axes?

Subject: specify parent map axes?

From: matt dash

Date: 26 Jun, 2007 12:53:19

Message: 1 of 5

Hi all,
I'm plotting lines on a map using linem and I would like to specify a
particular map axes as the parent. I can accomplish this by preceding
linem with something like:

axes(maphandle)

but if I instead try to specify the target map as a property pair
within linem (by using ...'parent',maphandle...) i get the error:
??? Error using ==> linem
Not a map axes. Select a map axes or use AXESM to define one.

I'd much rather use the second syntax since it's a lot faster...does
anyone know why this doesnt work?

ps,
maphandle is the handle to an axes that I have turned into a map
using the commands:

axes(maphandle)
handles.maxes=axesm(.......)

(as far as I know it is also not possible to use property/value pairs
to specify a target axes to the axesm command)

Subject: specify parent map axes?

From: Kelly

Date: 26 Jun, 2007 13:30:24

Message: 2 of 5

matt dash wrote:

> Hi all,
> I'm plotting lines on a map using linem and I would like to specify
> a
> particular map axes as the parent. I can accomplish this by
> preceding
> linem with something like:
>
> axes(maphandle)
>
> but if I instead try to specify the target map as a property pair
> within linem (by using ...'parent',maphandle...) i get the error:
> ??? Error using ==> linem
> Not a map axes. Select a map axes or use AXESM to define one.
>
> I'd much rather use the second syntax since it's a lot
> faster...does
> anyone know why this doesnt work?
>
> ps,
> maphandle is the handle to an axes that I have turned into a map
> using the commands:
>
> axes(maphandle)
> handles.maxes=axesm(.......)
>
> (as far as I know it is also not possible to use property/value
> pairs
> to specify a target axes to the axesm command)
  
Could you give a little more detail of the code you're using? I
tried to see if I could replicate the error using a simple example,
and haven't been able to. However, I'm definitely seeing some weird
stuff. The following snippet runs without error, but linem seems to
be getting confused with projections.

load coast;
f = figure;
a1 = subplot(2,1,1);
axes(a1);
m1 = axesm('mercator');
a2 = subplot(2,1,2);
axes(a2);
m2 = axesm('lambert');
linem(lat, long, 'parent', a1, 'color', 'b');
linem(lat, long, 'parent', a2, 'color', 'r');
setm(m1, 'frame', 'on');

I'll see if I can figure out what's going on in my code here.

And to your other comment, yes, you're right that you can't directly
specify a parent axis via axesm.
setm(m2, 'frame', 'on');

Subject: specify parent map axes?

From: matt dash

Date: 26 Jun, 2007 14:24:44

Message: 3 of 5

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

Subject: specify parent map axes?

From: Kelly

Date: 26 Jun, 2007 17:11:01

Message: 4 of 5

matt dash wrote:

> 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!

Actually, the reason mine works is that I made both subplots map
axes. So even though I had switched the focus to a different plot, I
avoided the error meassage you found. But the bug was still
manifesting itself by plotting the wrong projection.

This does seem to be a bug in linem. If you look at line 129 of the
linem code,

[mstruct,msg] = gcm;

you'll see it does grabs the mstruct data before it begins plotting.
But instead of checking the axis you specified using the 'parent'
property, it completely ignores this command and checks whatever the
current axis is, and throws an error if this axis doesn't hold a map
axis.

I'd go ahead and report this bug to The Mathorks. To get it working
properly, you'll probably have to modify linem to parse the inputs
and look for a parent axis to feed to gcm in this line rather than
always defaulting to the current one.

-Kelly

Subject: specify parent map axes?

From: matt dash

Date: 27 Jun, 2007 12:17:31

Message: 5 of 5

ah, that clears things up... thanks a lot!

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

rssFeed for this Thread
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com