Re: Square pixels in surface/lego plots [message #8402] |
Fri, 07 March 1997 00:00 |
Robert.M.Candey
Messages: 23 Registered: June 1995
|
Junior Member |
|
|
In article <5fpj1k$fsn$1@lll-winken.llnl.gov>, bmac@igpp.llnl.gov (Bruce
Macintosh) wrote:
> Let us say I have a rectangular array,
>
> SAO56102=fltarr(60,30)
>
> that I wish to make a lego-style surface plot of.
>
> What's the simplest way to make sure the pixels come out reasonably
> square?
> . . .
> Any easier approaches?
>
> Bruce
The following is an old routine I used that you might be able to adapt.
Unfortunately it makes a dummy plot first. David Fanning probably has
other ideas on his web pages. Hopefully RSI will add /iso to all plot
routines like they have in map_set.
pro even_scale, x, y
; CREATE EVEN (exact) SCALE frame with equal data units plotting as equal
; distances on the X and Y axes
; This is extracted from Plot_even.pro created by
; Bobby Candey, Atlantic Research Corp. 1991 April 11; S. F. Fung 9/10/91.
; alters !p.position and !p.multi and !x/y.range and makes a dummy plot
!p.position = 0
!p.multi = 0 ; reset to 1 plot per page
if (n_params(0) eq 2) then begin
!x.range = [min(x), max(x)]
!y.range = [min(y), max(y)]
endif
plot,[0,1],[0,1] ; dummy plot to set !x/y.crange and !x/y.window
device,/close
wx = !x.window & wy = !y.window ; window size in normalized coordinates
xr = !x.crange(1) - !x.crange(0) ; data range in data coordinates
yr = !y.crange(1) - !y.crange(0)
xdevice = wx * float(!d.x_size) ; current window in pixels
ydevice = wy * float(!d.y_size)
xrdevice = xdevice(1) - xdevice(0) ; current window width in pixels
yrdevice = ydevice(1) - ydevice(0)
xratio = xr / xrdevice ; data units per pixel
yratio = yr / yrdevice
ratio = max([xratio, yratio])
newxmaxnorm = (xr / ratio + xdevice(0)) / float(!d.x_size)
newymaxnorm = (yr / ratio + ydevice(0)) / float(!d.y_size)
!p.position = [wx(0), wy(0), newxmaxnorm, newymaxnorm]
return
end
--
Robert.M.Candey@gsfc.nasa.gov
NASA Goddard Space Flight Center, Code 632
Greenbelt, MD 20771 USA 1-301-286-6707
|
|
|