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:
Adding text to geoshow

Subject: Adding text to geoshow

From: August 2wrcozp0

Date: 28 Oct, 2011 12:15:30

Message: 1 of 8

Hej!

I have a problem with adding text to a geoshow figure, perhaps anyone could help me?

The following plot works perfectly fine, where B is gridded data points:
geoshow (lat,lon,B);

However, when I want to add text:
geoshow (lat,lon,B);
text (lat1,lon1,'help');

The text ends up below the graph.

How do I move the text to the front, so I can see it??

Thanks in advance!

Subject: Adding text to geoshow

From: Rob Comer

Date: 28 Oct, 2011 22:16:30

Message: 2 of 8

"August 2wrcozp0" <august.andersson@itm.su.se> wrote in message <j8e6d2$vv$1@newscl01ah.mathworks.com>...
> The following plot works perfectly fine, where B is gridded data points:
> geoshow (lat,lon,B);
>
> However, when I want to add text:
> geoshow (lat,lon,B);
> text (lat1,lon1,'help');
>
> The text ends up below the graph.

Do you mean that the text is visible, but it appears in the wrong place? If you are plotting in a map axes (created with axesm, worldmap, or usamap), try using textm instead of text. If not, you may need to swap lat1 and lon1 in your call to text.

Rob Comer
Mapping Toolbox Development
MathWorks

Subject: Adding text to geoshow

From: August 2wrcozp0

Date: 31 Oct, 2011 16:14:13

Message: 3 of 8

Thanks for your reply Rob!

I actually tried with both text and textm, but wrote text here by mistake.
Textm plots the text at the right spot. I can see that, since when I set facealpha to 0.2 for the geoshow comand I see the text. But when facealpha is set to 1, the text is no longer visible. Somehow the text must end up in a lower level or something like that. How do I move it up?

Subject: Adding text to geoshow

From: Kelly Kearney

Date: 31 Oct, 2011 19:38:12

Message: 4 of 8

"August 2wrcozp0" <august.andersson@itm.su.se> wrote in message <j8mhgl$65q$1@newscl01ah.mathworks.com>...
> Thanks for your reply Rob!
>
> I actually tried with both text and textm, but wrote text here by mistake.
> Textm plots the text at the right spot. I can see that, since when I set facealpha to 0.2 for the geoshow comand I see the text. But when facealpha is set to 1, the text is no longer visible. Somehow the text must end up in a lower level or something like that. How do I move it up?


Try uistack(h, 'top'), where h is the handle of your text object.

-Kelly

Subject: Adding text to geoshow

From: August 2wrcozp0

Date: 1 Nov, 2011 08:47:27

Message: 5 of 8

It appears that this problem is related to the display of the figure in matlab, rather than the figure itself. If I save the image as a PDF file, the text appears in the right position, ontop of the geoshow grid. Strange....

Subject: Adding text to geoshow

From: August 2wrcozp0

Date: 1 Nov, 2011 09:37:10

Message: 6 of 8

However, when I use contourm:
contourm (lat,lon,B);
textm(lat1,lon1,'help');
The problem is remains. I am wondering why plotting maps is different from the normal plotting procedures?
Using:
contour(lon,lat,B);
text(lon1,lat1,'help');
moves the text ontop without any special tricks....

Subject: Adding text to geoshow

From: Felipe

Date: 28 Nov, 2011 05:59:09

Message: 7 of 8

"August 2wrcozp0" <august.andersson@itm.su.se> wrote in message <j8oek6$d5a$1@newscl01ah.mathworks.com>...
> However, when I use contourm:
> contourm (lat,lon,B);
> textm(lat1,lon1,'help');
> The problem is remains. I am wondering why plotting maps is different from the normal plotting procedures?
> Using:
> contour(lon,lat,B);
> text(lon1,lat1,'help');
> moves the text ontop without any special tricks....

%The map axes
R=worldmap(latlim, lonlim);
%plot something
    geoshow(R,map,RefMap,'DisplayType','texturemap')
did you try?
textm(lat,lon,'help','Color',[1 1 1],...
                'FontSize',9,'FontWeight','bold',...
                'HorizontalAlignment','center')

Subject: Adding text to geoshow

From: Rob Comer

Date: 29 Nov, 2011 02:40:08

Message: 8 of 8

"August 2wrcozp0" <august.andersson@itm.su.se> wrote in message <j8oek6$d5a$1@newscl01ah.mathworks.com>...
> However, when I use contourm:
> contourm (lat,lon,B);
> textm(lat1,lon1,'help');
> The problem is remains. I am wondering why plotting maps is different from the normal plotting procedures?
> Using:
> contour(lon,lat,B);
> text(lon1,lat1,'help');
> moves the text ontop without any special tricks....

I'm not seeing this problem -- with either geoshow or contourm, but I don't know what your inputs (lat, lon, B, lat1, and lon1) are.

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