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

Home » Public Forums » archive » reversing background color in maps
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
reversing background color in maps [message #14332] Fri, 19 February 1999 00:00 Go to next message
T Bowers is currently offline  T Bowers
Messages: 56
Registered: May 1998
Member
OK, guys and gals...
I'm trying to create a plot here that has a world map overplotted
with my data positions. I can do that OK. My problem is that
it plots as white on a black background. I need to reverse this
and have a white background. For simplicity, I'm using the
tek_color ct. I thought, hmmm... I'll just swap the black and
white entries in the ct, and I'll be set. Right? Like this...

;//Save original color table
tvlct, old_r,old_g,old_b, /get

;//Set up colors for plotting
tek_color
BLACK = 0
WHITE = 1
RED = 2
GREEN = 3
BLUE = 4
ORANGE = 8
;//Reverse BLACK/WHITE
tvlct, 255,255,255,0
tvlct, 0,0,0,1
WHITE = 0
BLACK = 1

When I run it like this, I do get a white background but the box labels
(from map_grid,/box) are gone and I get the lat lon grid lines in black
even tho I didn't want grid lines at all (/grid not set in map_set). Anybody
know of a way to get this workin' correctly??

print, !version
{ x86 Win32 Windows 5.0.2 Jul 23 1997}
I'm kinda in the process of upgrading to 5.2, so please let me know if
this works as wanted in 5.2.

Thanks alot,
t bowers

Here's pretty much what the plotting stuff looks like if ya wanna know.

;//Find all unigue lons/lats in data
lon = (dataArray[lonIndex,*])[UNIQ(dataArray[lonIndex,*],
SORT(dataArray[lonIndex,*]))]
lat = (dataArray[latIndex,*])[UNIQ(dataArray[latIndex,*],
SORT(dataArray[latIndex,*]))]

;//Append current lon/lat to lon/lat array list. I'll plot these arrays
(lons/lats) as data positions
lons = [lons,lon]
lats = [lats,lat]

;//Set up a margin that's a certain % of lat lon delta.
;// e.g 0.15 = margin extending 15% beyond bounds of data
margin = 0.15

;//I'll use these in upcoming call to map_set
minLon = min(lons,max=maxLon)
minLat = min(lats,max=maxLat)
lonMargin = (maxLon - minLon) * margin
latMargin = (maxLat - minLat) * margin
midLon = median(lons, /even)
midLat = median(lats, /even)

;//Set up map centered on data and extending margin % beyond data positions
map_set, midLat, midLon, $
/TRANSVERSE_MERCATOR, $
/ISOTROPIC, $
xmargin=[3,3], $
ymargin=[2,2], $
limit=[(minLat - latMargin), (minLon - lonMargin), $
(maxLat + latMargin), (maxLon + lonMargin)]

;//Make it look good with /box
map_grid, /box

;//Overlay coasts, etc.
map_continents, /coasts, color=GREEN, /hires
map_continents, /rivers, color=BLUE, /hires
map_continents, /countries, /USA, color=ORANGE, /hires

;//Overplot the data positions
oplot, lons, lats, psym=3, color = RED

;//Restore original color table
tvlct, old_r,old_g,old_b

--
Todd Bowers
PSI-MSAAP Bldg. 9121
Stennis Space Center, MS
tbowers@nrlssc.navy.mil
Re: reversing background color in maps [message #14426 is a reply to message #14332] Mon, 22 February 1999 00:00 Go to previous message
wmc is currently offline  wmc
Messages: 117
Registered: February 1995
Senior Member
T Bowers <tbowers@nrlssc.navy.mil> wrote:
> ...I need to reverse this and have a white background.

> tvlct, 255,255,255,0
> tvlct, 0,0,0,1
> WHITE = 0
> BLACK = 1

> When I run it like this, I do get a white background but the box labels
> (from map_grid,/box) are gone and I get the lat lon grid lines in black
> even tho I didn't want grid lines at all (/grid not set in map_set).

As I understand it, IDL plots background using index !p.background
and foreground with !p.color. These are normally 0 and 255, and are
normally black and white respectively. If you just make index 0 into
white, then !p.background and !p.color point to the same colour.

So: I think you can just interchange !p.background and !p.color, or if
you want to follow your scheme, do tvlct,0,0,0,!p.color & black=!p.color

-W.

--
William M Connolley | wmc@bas.ac.uk | http://www.nbs.ac.uk/public/icd/wmc/
Climate Modeller, British Antarctic Survey | Disclaimer: I speak for myself
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: IDL and Image Segmentation
Next Topic: Realigning command in IDL.

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

Current Time: Thu Oct 09 13:59:32 PDT 2025

Total time taken to generate the page: 1.36154 seconds