comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: latiude/ longitude legend outside the map
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: latiude/ longitude legend outside the map [message #29347] Wed, 13 February 2002 07:40
Liam E. Gumley is currently offline  Liam E. Gumley
Messages: 378
Registered: January 2000
Senior Member
Marco Trommler wrote:
> I would like to generate a Map with grid lines and a legend with the values
> of the latitude or longitude of the grid lines outside of the image (aligned
> to the map border)
>
> WINDOW, ...
> MAP_SET .....,,/cylindrical, xmargin=3,ymargin=3
> MAP_GRID, LABEL=2, LATDEL=5, LONDEL=10, LONLAB=reg.latmin[r]
>
> prints the values of the longitude on the min. latitude grid line of my map
> (at the lower border but inside the map)
>
> MAP_GRID, LABEL=2, LATDEL=5, LONDEL=10, LONLAB=reg.latmin[r]-0.5
>
> should print the values with space 0.5 under the lowest border, but the
> program doesn't make it..... Where is the mistake???

Try using the MAP_GRID keyword BOX_AXES:

map_set, 43, -89.5, scale=10e6, $
/usa, xmargin=[3, 3], ymargin=[3,3]
map_grid, latdel=2, londel=2, charsize=0.75, /box_axes

Cheers,
Liam.
Practical IDL Programming
http://www.gumley.com/
Re: latiude/ longitude legend outside the map [message #29349 is a reply to message #29347] Wed, 13 February 2002 07:35 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Kenneth Bowman (k-bowman@null.tamu.edu) writes:

>> A little fooling around will quickly give you what you want.
>
> ^^^^^^^
>
> Having the espresso this morning, eh?

It's probably just me, but I've always found legends
to be an inexact science. I always have to play
around for 5-10 minutes getting the thingys lined
up with the whatadyacallits. It would probably help
if I wasn't so anal about the whole thing. :-(

More, or less, espresso, do you think?

Cheers,

David

--
David W. Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
Re: latiude/ longitude legend outside the map [message #29351 is a reply to message #29349] Wed, 13 February 2002 06:50 Go to previous message
K. Bowman is currently offline  K. Bowman
Messages: 330
Registered: May 2000
Senior Member
In article <MPG.16d421b2f215464f989804@news.frii.com>,
David Fanning <david@dfanning.com> wrote:

> A little fooling around will quickly give you what you want.

^^^^^^^

Having the espresso this morning, eh?

Let's just say that map labeling in MAP_SET looks exactly like NCAR Graphics
ca. 1980, and that getting labels to look really good is a pain.

This is an old program that I haven't used in a while, but it will give
you a starting point.

Ken


;*********************************************************** *******************
PRO TOMS5EPSFMAP, ..., SH = sh, NH = nh

; This procedure draws a global (default), SH, or NH map.
; It has been customized for the EPSF device.

; Put your data in the ... above

title = 'map title'


; Set map projection


daspect = FLOAT(!D.Y_SIZE)/FLOAT(!D.X_SIZE)
IF KEYWORD_SET(nh) THEN BEGIN
x0 = 0.10
y0 = 0.05
x1 = 0.90
y1 = 0.85
!P.POSITION = [x0, y0, x1, y1]
MAP_SET, 90, 0, -90, /AZIMUTHAL, $ ;Set the map projection
LIMIT = [ 0, -180, 90, 180], /NOBORDER, /ISOTROPIC
j1 = nyy5/2 ;Southern edge of data area
j2 = nyy5-1 ;Northern edge of data area
ENDIF ELSE IF KEYWORD_SET(sh) THEN BEGIN
x0 = 0.10
y0 = 0.05
x1 = 0.90
y1 = 0.85
!P.POSITION = [x0, y0, x1, y1]
MAP_SET, -90, 0, 90, /AZIMUTHAL, $ ;Set the map projection
LIMIT = [-90, -180, 0, 180], /NOBORDER, /ISOTROPIC
j1 = 0 ;Southern edge of data area
j2 = nyy5/2 ;Northern edge of data area
ENDIF ELSE BEGIN
aspect = 0.5 ;Set the aspect ratio
x0 = 0.06
y0 = 0.48 - 0.45*(aspect/daspect)
x1 = 0.96
y1 = 0.48 + 0.45*(aspect/daspect)
!P.POSITION = [x0, y0, x1, y1]
MAP_SET, 0, 0, /CYLINDRICAL, $ ;Set the map projection
LIMIT = [-90, -180, 90, 180], /NOBORDER, /ISOTROPIC
j1 = 0 ;Southern edge of data area
j2 = nyy5-1 ;Northern edge of data area
ENDELSE


; Draw map here ....


IF KEYWORD_SET(nh) THEN BEGIN

DEVICE, FONT_SIZE=14
ch_size = CONVERT_COORD(!D.X_CH_SIZE, !D.Y_CH_SIZE, /DEVICE, /TO_NORMAL)
dy = ch_size(1)
XYOUTS, 0.5, 0.95, title, /NORMAL, ALIGNMENT = 0.5

DEVICE, FONT_SIZE=10
ch_size = CONVERT_COORD(!D.X_CH_SIZE, !D.Y_CH_SIZE, /DEVICE, /TO_NORMAL)
dy = ch_size(1)
xy = CONVERT_COORD(FLOAT(0.0), 0.0, /DATA, /TO_NORMAL)
xlabel = STRTRIM(STRING(0) + deg, 1)
XYOUTS, xy(0)+0.05, xy(1)-(0.5*dy), xlabel, /NORMAL, ALIGNMENT = 0.5

xy = CONVERT_COORD(FLOAT(180.0), 0.0, /DATA, /TO_NORMAL)
xlabel = STRTRIM(STRING(180) + deg, 1)
XYOUTS, xy(0)-0.05, xy(1)-(0.5*dy), xlabel, /NORMAL, ALIGNMENT = 0.5

xy = CONVERT_COORD(FLOAT(90.0), 0.0, /DATA, /TO_NORMAL)
xlabel = STRTRIM(STRING(90) + deg + ' E', 1)
XYOUTS, xy(0), xy(1)+(0.5*dy), xlabel, /NORMAL, ALIGNMENT = 0.5

xy = CONVERT_COORD(FLOAT(-90.0), 0.0, /DATA, /TO_NORMAL)
xlabel = STRTRIM(STRING(90) + deg + ' W', 1)
XYOUTS, xy(0), xy(1)-(1.5*dy), xlabel, /NORMAL, ALIGNMENT = 0.5

FOR yy = 30, 60, 30 DO BEGIN
xy = CONVERT_COORD(-135.0, FLOAT(yy), /DATA, /TO_NORMAL)
IF(yy LT 0) THEN hemi = ' S' ELSE IF(yy GT 0) THEN hemi = ' N' ELSE hemi = ' '
ylabel = STRTRIM(STRING(ABS(yy)) + deg + hemi, 1)
XYOUTS, xy(0)-0.0075, xy(1)-dy/2, ylabel, /NORMAL, ALIGNMENT = 0.5
ENDFOR

ENDIF ELSE IF KEYWORD_SET(sh) THEN BEGIN

DEVICE, FONT_SIZE=14
ch_size = CONVERT_COORD(!D.X_CH_SIZE, !D.Y_CH_SIZE, /DEVICE, /TO_NORMAL)
dy = ch_size(1)
XYOUTS, 0.5, 0.95, title, /NORMAL, ALIGNMENT = 0.5

DEVICE, FONT_SIZE=10
ch_size = CONVERT_COORD(!D.X_CH_SIZE, !D.Y_CH_SIZE, /DEVICE, /TO_NORMAL)
dy = ch_size(1)
xy = CONVERT_COORD(FLOAT(0.0), 0.0, /DATA, /TO_NORMAL)
xlabel = STRTRIM(STRING(0) + deg, 1)
XYOUTS, xy(0)+0.05, xy(1)-(0.5*dy), xlabel, /NORMAL, ALIGNMENT = 0.5

xy = CONVERT_COORD(FLOAT(180.0), 0.0, /DATA, /TO_NORMAL)
xlabel = STRTRIM(STRING(180) + deg, 1)
XYOUTS, xy(0)-0.05, xy(1)-(0.5*dy), xlabel, /NORMAL, ALIGNMENT = 0.5

xy = CONVERT_COORD(FLOAT(90.0), 0.0, /DATA, /TO_NORMAL)
xlabel = STRTRIM(STRING(90) + deg + ' E', 1)
XYOUTS, xy(0), xy(1)-(1.5*dy), xlabel, /NORMAL, ALIGNMENT = 0.5

xy = CONVERT_COORD(FLOAT(-90.0), 0.0, /DATA, /TO_NORMAL)
xlabel = STRTRIM(STRING(90) + deg + ' W', 1)
XYOUTS, xy(0), xy(1)+(0.5*dy), xlabel, /NORMAL, ALIGNMENT = 0.5

FOR yy = -60, -30, 30 DO BEGIN
xy = CONVERT_COORD(-135.0, FLOAT(yy), /DATA, /TO_NORMAL)
IF(yy LT 0) THEN hemi = ' S' ELSE IF(yy GT 0) THEN hemi = ' N' ELSE hemi = ' '
ylabel = STRTRIM(STRING(ABS(yy)) + deg + hemi, 1)
XYOUTS, xy(0)-0.0075, xy(1)-dy/2, ylabel, /NORMAL, ALIGNMENT = 0.5
ENDFOR

ENDIF ELSE BEGIN

DEVICE, FONT_SIZE=14
ch_size = CONVERT_COORD(!D.X_CH_SIZE, !D.Y_CH_SIZE, /DEVICE, /TO_NORMAL)
dy = ch_size(1)
xy = CONVERT_COORD(0.0, 90.0, /DATA, /TO_NORMAL)
XYOUTS, xy(0), xy(1)+1.5*dy, title, /NORMAL, ALIGNMENT = 0.5

DEVICE, FONT_SIZE=10
ch_size = CONVERT_COORD(!D.X_CH_SIZE, !D.Y_CH_SIZE, /DEVICE, /TO_NORMAL)
dy = ch_size(1)
FOR xx = -180, 180, 90 DO BEGIN
xy = CONVERT_COORD(FLOAT(xx), -90.0, /DATA, /TO_NORMAL)
IF(xx LT 0) THEN hemi = ' W' ELSE IF(xx GT 0) THEN hemi = ' E' ELSE hemi = ''
xlabel = STRTRIM(STRING(ABS(xx)) + deg + hemi, 1)
XYOUTS, xy(0), xy(1)-(1.7*dy), xlabel, /NORMAL, ALIGNMENT = 0.5
ENDFOR

FOR yy = -90, 90, 30 DO BEGIN
xy = CONVERT_COORD(-180.0, FLOAT(yy), /DATA, /TO_NORMAL)
IF(yy LT 0) THEN hemi = ' S' ELSE IF(yy GT 0) THEN hemi = ' N' ELSE hemi = ' '
ylabel = STRTRIM(STRING(ABS(yy)) + deg + hemi, 1)
XYOUTS, xy(0)-0.0075, xy(1)-dy/2, ylabel, /NORMAL, ALIGNMENT = 1.0
ENDFOR

ENDELSE

END
Re: latiude/ longitude legend outside the map [message #29355 is a reply to message #29351] Wed, 13 February 2002 06:10 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Marco Trommler (marco.trommler@ipf.tuwien.ac.at) writes:

> I would like to generate a Map with grid lines and a legend with the values
> of the latitude or longitude of the grid lines outside of the image (aligned
> to the map border)
>
> WINDOW, ...
> MAP_SET .....,,/cylindrical, xmargin=3,ymargin=3
> MAP_GRID, LABEL=2, LATDEL=5, LONDEL=10, LONLAB=reg.latmin[r]
>
> prints the values of the longitude on the min. latitude grid line of my map
> (at the lower border but inside the map)
>
> MAP_GRID, LABEL=2, LATDEL=5, LONDEL=10, LONLAB=reg.latmin[r]-0.5
>
> should print the values with space 0.5 under the lowest border, but the
> program doesn't make it..... Where is the mistake???

I think the mistake is trying to use IDL's map
projection routines to do this. :-)

I would position the map projection with the POSITION
keyword (rather than specifying the margins) to give
yourself some space to write the legend. Then, I would
write the legend with XYOUTS and PLOTS, again using
normalized coordinates to position things. A little
fooling around will quickly give you what you want.

Cheers,

David

--
David W. Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Object method compiling
Next Topic: Re: Object/Direct Graphics Question

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Sat Oct 11 11:53:14 PDT 2025

Total time taken to generate the page: 1.12056 seconds