Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Problem: worldmap after imshow or surf(peaks)

Subject: Problem: worldmap after imshow or surf(peaks)

From: Jax Cao

Date: 20 Jul, 2010 04:32:04

Message: 1 of 2

Hi,

I had issues in drawing worldmap after imshow or surf commands, hope somebody could help me. I put the corresponding problematic figures at

http://jaxforum.webs.com/apps/photos/album?albumid=9550438

for your information.

Here are the codes with my comments parenthesized:

sz = get(0, 'ScreenSize');
im1 = rand(300);
latlim = [20 83]; lonlim = [-180 -80];
handle = figure('position', [150 150 sz(3)*3/5 sz(3)*3/10]);
ah1 = axes('parent', handle, 'position', [0.04 0.06 .45 .88]);
ah2 = axes('parent', handle, 'position', [0.53 0.06 .45 .88]);
axes(ah1)
imshow(im1)
worldmap(latlim, lonlim)

{Two problems occur. First, there is a rectangular box overlapping the right side of the figure. Second, the worldmap is drawn upside down. if I type}

worldmap(latlim, lonlim)

{this removes the box but the map is still upside down. Draw worldmap in the second axes}

axes(ah2)
worldmap(latlim, lonlim)

{Now the worldmap is correct}

drawing worldmap after surf command is even worse. If I draw surf after worldmap I should use hold off to remove the effect of the world map. However there is always the problem with the worldmap command after surf.
I did:

delete(handle); delete(ah1); delete(ah2);
handle = figure('position', [150 150 sz(3)*3/5 sz(3)*3/10]);
ah1 = axes('parent', handle, 'position', [0.04 0.06 .45 .88]);
ah2 = axes('parent', handle, 'position', [0.53 0.06 .45 .88]);
axes(ah1)
surf(peaks)
worldmap(latlim, lonlim)
axes(ah2)
surf(peaks)
hold off
worldmap(latlim, lonlim)

both axes produce the same funny pictures.

Thanks,

Jax Cao

Subject: Problem: worldmap after imshow or surf(peaks)

From: Rob Comer

Date: 11 Nov, 2010 21:11:03

Message: 2 of 2

"Jax Cao" <guangxia@hawaii.edu> wrote in message <i238s4$lq0$1@fred.mathworks.com>...
> Hi,
>
> I had issues in drawing worldmap after imshow or surf commands, hope somebody could help me. I put the corresponding problematic figures at
>
> http://jaxforum.webs.com/apps/photos/album?albumid=9550438
>
> for your information.
>
> Here are the codes with my comments parenthesized:
>
> sz = get(0, 'ScreenSize');
> im1 = rand(300);
> latlim = [20 83]; lonlim = [-180 -80];
> handle = figure('position', [150 150 sz(3)*3/5 sz(3)*3/10]);
> ah1 = axes('parent', handle, 'position', [0.04 0.06 .45 .88]);
> ah2 = axes('parent', handle, 'position', [0.53 0.06 .45 .88]);
> axes(ah1)
> imshow(im1)
> worldmap(latlim, lonlim)
>
> {Two problems occur. First, there is a rectangular box overlapping the right side of the figure. Second, the worldmap is drawn upside down. if I type}
>
> worldmap(latlim, lonlim)
>
> {this removes the box but the map is still upside down. Draw worldmap in the second axes}
>
> axes(ah2)
> worldmap(latlim, lonlim)
>
> {Now the worldmap is correct}
>
> drawing worldmap after surf command is even worse. If I draw surf after worldmap I should use hold off to remove the effect of the world map. However there is always the problem with the worldmap command after surf.
> I did:
>
> delete(handle); delete(ah1); delete(ah2);
> handle = figure('position', [150 150 sz(3)*3/5 sz(3)*3/10]);
> ah1 = axes('parent', handle, 'position', [0.04 0.06 .45 .88]);
> ah2 = axes('parent', handle, 'position', [0.53 0.06 .45 .88]);
> axes(ah1)
> surf(peaks)
> worldmap(latlim, lonlim)
> axes(ah2)
> surf(peaks)
> hold off
> worldmap(latlim, lonlim)
>
> both axes produce the same funny pictures.
>
> Thanks,
>
> Jax Cao

Jax,

You're seeing side effects of changes to axes properties that are made quietly by the image and surf commands.

In the case of image the YDir property is set to 'reverse'. The map will have north at the top if you restore YDir to its default value like this: set(ah1,'YDir','normal')

And the "rectangular box" is just the image that you created with this command: imshow(im1). Delete that image from the axes and the box will vanish.

Similarly, in the case of surf various camera properties are automatically changed from their defaults in order to give you a 3D perspective view. You can get back to a default, 2D view like this: view(ah1,2)

Hope this helps,

Rob Comer
Mapping Toolbox Development
MathWorks

Tags for this Thread

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.

Contact us